2 messages in org.python.python-bugs-list[ python-Bugs-919605 ] os.rename() si...
FromSent OnAttachments
SourceForge.netMar 19, 2004 12:02 pm 
SourceForge.netMar 20, 2004 4:25 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[ python-Bugs-919605 ] os.rename() silently overwrites filesActions...
From:SourceForge.net (nore@sourceforge.net)
Date:Mar 19, 2004 12:02:27 pm
List:org.python.python-bugs-list

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.

----------------------------------------------------------------------