merge from 3.1

This commit is contained in:
Ronald Oussoren 2011-05-06 10:57:22 +02:00
commit 78349b06af
3 changed files with 29 additions and 1 deletions

View file

@ -311,12 +311,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))