summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2002-09-08 20:43:59 (GMT)
committerRaymond Hettinger <python@rcn.com>2002-09-08 20:43:59 (GMT)
commit57e79459fa872c4fc1724e34b9d2f90d53aac818 (patch)
tree8fbc16ff278a45db195eb98c8a6921cbdaf9a5c3 /Lib
parent513069028fed8a43474a86bfa823bbd0753deca1 (diff)
downloadcpython-57e79459fa872c4fc1724e34b9d2f90d53aac818.zip
cpython-57e79459fa872c4fc1724e34b9d2f90d53aac818.tar.gz
cpython-57e79459fa872c4fc1724e34b9d2f90d53aac818.tar.bz2
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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/shutil.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 3076be9..0e60870 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -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')