Bugs item #919605, was opened at 2004-03-19 17:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=919605&group_id=5470
Category: Python Library
Group: Python 2.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Jozef Behran (jojoworks)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.rename() silently overwrites files
Initial Comment:
Python 2.2.2 from Mandrake GNU/Linux 9.0
os.rename() should throw an exception when the program
tries to rename file to an existing filename. Such a
situation is namely usually caused by a bug in the
calling program. The current behavior (silently
replacing old file content with the new one) is
dangerous to programmer's data.
If the program wants to overwrite files, it can use
try:
os.rename(old,new)
except IOError:
os.unlink(new)
os.rename(old,new)
or something similar to do so.
----------------------------------------------------------------------