[Python-ideas] Implementation of shutil.move

Christian Heimes lists at cheimes.de
Mon Aug 15 15:29:41 CEST 2011


Am 15.08.2011 14:59, schrieb David Townshend:
> I'll have a look at open() later and see if I can write a patch for python
> 3.  I'm not sure its worth that amount of work for python 2 at this stage in
> it's lifecycle.
> 
> I'll also have a look at whether its possible to provide a safe alternative
> to move and copyfile, even if it cannot be used on all systems. I'm not
> thinking of actively hostile environments so much as multi-user situations.

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

to implement the 'c' mode. I like the idea and I've been missing the
feature for a long time.


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.

Christian



More information about the Python-ideas mailing list