Commit 57e79459 authored by Raymond Hettinger's avatar Raymond Hettinger

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.
parent 51306902
...@@ -24,6 +24,11 @@ def copyfile(src, dst): ...@@ -24,6 +24,11 @@ def copyfile(src, dst):
"""Copy data from src to dst""" """Copy data from src to dst"""
fsrc = None fsrc = None
fdst = 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: try:
fsrc = open(src, 'rb') fsrc = open(src, 'rb')
fdst = open(dst, 'wb') fdst = open(dst, 'wb')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment