[Python-ideas] Implementation of shutil.move

David Townshend aquavitae69 at gmail.com
Mon Aug 15 15:58:45 CEST 2011


>
> You have to modify at least the C functions
>  Modules/_io/_iomodule.c:io_open()
>  Modules/_io/fileio.c:fileio_init()
> as well as the pure python implementation
>  Lib/_pyio.py


Thanks for the info - it will save me looking for it :-)

Well, that's basically what I was getting at. I don't like the idea of
> silently falling back to the unsafe thing one bit. It wouldn't be so
> bad to have something that tries to do it without any race conditions
> etc., and raises an exception if this isn't possible.


This may sound harsh. If you proposed changes don't survive hostiles
> environment then there is no reason in implementing them at all. It's
> the false sense of security Nick was talking about earlier. At best your
> solution is slightly less insecure but still insecure and a loophole for
> exploits. IMHO you should update the docs and explain why and how some
> operations are subjected to race conditions.


 So a new function, say safe_copy(), tries to copy securely. If it can't,
then an exception is raised.  The user can then do something like:

try:
    safe_copy(src, dst)
except Error:
    logging.warning('Unsafe copy in progress')
    copy2(src, dst)

My question now is whether there is really a need for this.  The other
option is, as Christian says, to document the problem and perhaps present an
recipe for avoiding it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110815/35f9a43d/attachment.html>


More information about the Python-ideas mailing list