summaryrefslogtreecommitdiffstats
path: root/Lib/shutil.py
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2011-05-06 08:23:04 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2011-05-06 08:23:04 (GMT)
commitf51738b10e83d0adf404ca989970a5b44700d685 (patch)
tree1fc30e8a697333459b9e0a8eb4ff14bd92084a96 /Lib/shutil.py
parentd92ab0806d38cc592f303545d649821daa802997 (diff)
downloadcpython-f51738b10e83d0adf404ca989970a5b44700d685.zip
cpython-f51738b10e83d0adf404ca989970a5b44700d685.tar.gz
cpython-f51738b10e83d0adf404ca989970a5b44700d685.tar.bz2
Fix for issue 10684: Folders get deleted when trying to change case with shutil.move (case insensitive file systems only)
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r--Lib/shutil.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 4862ae6..781840d 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -260,12 +260,18 @@ def move(src, dst):
"""
real_dst = dst
if os.path.isdir(dst):
+ if _samefile(src, dst):
+ # We might be on a case insensitive filesystem,
+ # perform the rename anyway.
+ os.rename(src, dst)
+ return
+
real_dst = os.path.join(dst, _basename(src))
if os.path.exists(real_dst):
raise Error("Destination path '%s' already exists" % real_dst)
try:
os.rename(src, real_dst)
- except OSError:
+ except OSError as exc:
if os.path.isdir(src):
if _destinsrc(src, dst):
raise Error("Cannot move a directory '%s' into itself '%s'." % (src, dst))