mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-113188: Fix shutil.copymode() on Windows (GH-113189)
Previously it worked differently if dst is a symbolic link: it modified the permission bits of dst itself rather than the file it points to if follow_symlinks is true or src is not a symbolic link, and did nothing if follow_symlinks is false and src is a symbolic link. Also document similar changes in shutil.copystat().
This commit is contained in:
parent
bdc8d667ab
commit
6e02d79f96
3 changed files with 24 additions and 14 deletions
|
@ -306,7 +306,12 @@ def copymode(src, dst, *, follow_symlinks=True):
|
|||
else:
|
||||
return
|
||||
else:
|
||||
stat_func, chmod_func = _stat, os.chmod
|
||||
stat_func = _stat
|
||||
if os.name == 'nt' and os.path.islink(dst):
|
||||
def chmod_func(*args):
|
||||
os.chmod(*args, follow_symlinks=True)
|
||||
else:
|
||||
chmod_func = os.chmod
|
||||
|
||||
st = stat_func(src)
|
||||
chmod_func(dst, stat.S_IMODE(st.st_mode))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue