This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author techtonik
Recipients Trundle, draghuram, eric.araujo, giampaolo.rodola, neologix, pitrou, r.david.murray, tarek, techtonik, vstinner
Date 2011-12-23.19:29:05
SpamBayes Score 7.123779e-11
Marked as misclassified No
Message-id <>
In-reply-to <>
2011/12/23 Charles-François Natali <>

> Charles-François Natali <> 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

BUT let me remind you that this bug is about "Atomic rename" which should
rollback in case of errors.
Date User Action Args
2011-12-23 19:29:06techtoniksetrecipients: + techtonik, pitrou, vstinner, draghuram, giampaolo.rodola, tarek, eric.araujo, r.david.murray, Trundle, neologix
2011-12-23 19:29:06techtoniklinkissue8828 messages
2011-12-23 19:29:05techtonikcreate