[Python-bugs-list] [ python-Bugs-490168 ] shutil.copy(path, path) deletes contents
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 08 Sep 2002 13:50:04 -0700
Bugs item #490168, was opened at 2001-12-07 04:16
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=490168&group_id=5470
Category: Python Library
Group: Python 2.1.1
>Status: Closed
>Resolution: Fixed
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: Raymond Hettinger (rhettinger)
Date: 2002-09-08 15:50
Message:
Logged In: YES
user_id=80475
Fixed for Py2.3.
See shutil.py 1.23
Also, see patch 604600.
----------------------------------------------------------------------
Comment By: Christos Georgiou (tzot)
Date: 2002-09-04 11:22
Message:
Logged In: YES
user_id=539787
See patch 604600
----------------------------------------------------------------------
Comment By: Matthias Kirst (mattkirst)
Date: 2001-12-10 06: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 05: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 12: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:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=490168&group_id=5470