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 neologix
Recipients Trundle, draghuram, eric.araujo, giampaolo.rodola, neologix, pitrou, r.david.murray, tarek, techtonik, vstinner
Date 2011-12-23.16:30:54
SpamBayes Score 5.244638e-12
Marked as misclassified No
Message-id <>
> How about overwrite=[None, True] with None meaning "OS default"?


> One of the Python advantages is providing predictable cross-platform 
> behavior. If we can't introduce nice API without BC break, it is not
> a reason to introduce ulgy API.

We cannot make rename() overwrite existing files by default (on Windows).
It's out of question, too much code might rely on this, and this may very well introduce security flaws.
If you're concerned with the semantics difference between platforms, well, there's not much we can do about it now. Java behaves in the same way, for example.

> I'm good with None/True, but that would imply that for posix rename 
> we'll need to implement the overwrite=False option...which would be a 
> nice thing (the shell mv command has -i for that).

The problem is that it's simply impossible to implement reliably.
I didn't check mv source code, but it must be using something like:

if '-i' and os.path.exists(target_path):
os.rename(src_path, target_path).

But there's a TOCTTOU race.
Date User Action Args
2011-12-23 16:30:55neologixsetrecipients: + neologix, pitrou, vstinner, draghuram, techtonik, giampaolo.rodola, tarek, eric.araujo, r.david.murray, Trundle
2011-12-23 16:30:55neologixsetmessageid: <>
2011-12-23 16:30:55neologixlinkissue8828 messages
2011-12-23 16:30:54neologixcreate