mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
Issue #2047: shutil.move() could believe that its destination path was
inside its source path if it began with the same letters (e.g. "src" vs. "src.new").
This commit is contained in:
parent
6ed1cb0014
commit
707c593761
3 changed files with 33 additions and 1 deletions
|
@ -265,4 +265,10 @@ def move(src, dst):
|
|||
os.unlink(src)
|
||||
|
||||
def destinsrc(src, dst):
|
||||
return abspath(dst).startswith(abspath(src))
|
||||
src = abspath(src)
|
||||
dst = abspath(dst)
|
||||
if not src.endswith(os.path.sep):
|
||||
src += os.path.sep
|
||||
if not dst.endswith(os.path.sep):
|
||||
dst += os.path.sep
|
||||
return dst.startswith(src)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue