anatoly techtonik <techto...@gmail.com> added the comment: 2011/12/23 Charles-François Natali <rep...@bugs.python.org>
> > Charles-François Natali <neolo...@free.fr> added the comment: > > > I propose quite the opposite. rename() should not overwrite existing > > files by default. > > 1. That's not what I understood from: > > os.rename(overwrite=True) to produce consistent cross-platform > > behavior. > > 2. The above argument on backward incompatible change applies in exactly > the same way (just exchange Windows for POSIX). > > 3. As explained above, it can not be done reliably on POSIX (TOCTTOU race). os.rename(overwrite=False) by default will do less harm than the opposite, so I'd say it is a way to go even if it can not be reliably done on POSIX. But I believe correct file system that supports transactions will make it possible to do reliably on POSIX too. Then I believe that having a small chance of overwriting file just created at exactly the same moment on a POSIX is a small price to pay for function that does safety check before rename on a platform that doesn't have such functionality at all. If you need this functionality - you will still do 'if exists ... rename' and the TOCTTOU race will affect you. So, the only exit is to place a little sign "in some extreme cases Linux suffers from TOCTTOU problem when renaming files without overwriting, so keep that in mind". BUT let me remind you that this bug is about "Atomic rename" which should rollback in case of errors. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8828> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com