[Python-bugs-list] [ python-Bugs-490168 ] shutil.copy(path, path) deletes contents
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 10 Dec 2001 03:06:32 -0800
Bugs item #490168, was opened at 2001-12-07 01:16
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=490168&group_id=5470
Category: Python Library
Group: Python 2.1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: shutil.copy(path, path) deletes contents
Initial Comment:
If source equals destination path the contents of the
file is deleted.
----------------------------------------------------------------------
Comment By: Matthias Kirst (mattkirst)
Date: 2001-12-10 03:06
Message:
Logged In: YES
user_id=397984
That's correct when using the command interactively.
But when the command is used in an environment where source
and destination path come from user interactions over a GUI
for instance the programmer won't check for the source and
destination path each time the command is called.
In my example I had a relative and an absolute path to
compare. So I would have had the relative path tracked
programmatically. At the end it seemed clearer to me to
read the source file out, create an empty destination
(open "w+") and write the dump to this file.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2001-12-10 02:42
Message:
Logged In: YES
user_id=6656
To the OP, if you're paying attention: shutil is pretty
useless. You might consider using distutils.file_util
instead (though I don't know if that suffers from this
"problem").
I wanted to do somthing about this before 2.2, sigh...
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-08 09:17
Message:
Logged In: YES
user_id=6380
I know the Unix 'cp' command tests for this condition, but
shouldn't this fall in the category of "don't do that, then"
in the Python world? How stupid do we expect the programmer
to be?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=490168&group_id=5470