[3.11] bpo-26791: Update shutil.move() to provide the same symlink move behavior as the mv shell when moving a symlink into a directory that is the target of the symlink (GH-21759) (GH-113518)

(cherry picked from commit c66b577d9f)

Co-authored-by: Jeffrey Kintscher <49998481+websurfer5@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2023-12-27 18:03:45 +01:00 committed by GitHub
parent a1f0118a26
commit 54927cd21a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 1 deletions

View file

@ -837,7 +837,7 @@ def move(src, dst, copy_function=copy2):
sys.audit("shutil.move", src, dst)
real_dst = dst
if os.path.isdir(dst):
if _samefile(src, dst):
if _samefile(src, dst) and not os.path.islink(src):
# We might be on a case insensitive filesystem,
# perform the rename anyway.
os.rename(src, dst)