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.

classification
Title: Portability issue: os.rename behaves differently on win32
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: cs_, draghuram, loewis
Priority: normal Keywords:

Created on 2007-04-03 16:17 by cs_, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg31693 - (view) Author: cs_ (cs_) Date: 2007-04-03 16:17
os.rename(src, dst) fails on Windows if dst already exist and regular file. On Unixes, it does not fail, and silently overwrites dst. It's better to use MoveFileEx(src, dst, MOVEFILE_REPLACE_EXISTING) when moving regular files under Win32 to make it behave consistent way.
msg31694 - (view) Author: Raghuram Devarakonda (draghuram) (Python triager) Date: 2007-04-12 16:35

From MSDN document and googling, it does look like MOVEFILE_REPLACE_EXISTING guarantees atomicity for rename operation. I will see if I can come up with a patch (I will first need to learn building python on windows).
msg31695 - (view) Author: Raghuram Devarakonda (draghuram) (Python triager) Date: 2007-04-22 22:48

I submitted a patch for this (1704547)
msg31696 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-05-01 15:02
This change would be an incompatible change; see the discussion of the proposed patch. Closing this report as "won't fix".
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44800
2007-04-03 16:17:31cs_create