shutil.copyfile(src,dst) was clobbering the file when the src and dst were

the same.   Added check to verify the two names are not the same.  Does not
check the actual files to see if there is a symbolic link.

Closes SF bug 490165 and Tzot's patch 604600.
This commit is contained in:
Raymond Hettinger 2002-09-08 20:43:59 +00:00
parent 513069028f
commit 57e79459fa
1 changed files with 5 additions and 0 deletions

View File

@ -24,6 +24,11 @@ def copyfile(src, dst):
"""Copy data from src to dst"""
fsrc = None
fdst = None
# check for same pathname; all platforms
_src = os.path.normcase(os.path.abspath(src))
_dst = os.path.normcase(os.path.abspath(dst))
if _src == _dst:
return
try:
fsrc = open(src, 'rb')
fdst = open(dst, 'wb')