You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
os.chmod() does not follow symlinks on Windows #59616
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2012-07-21.08:31:23.124>labels= ['type-feature', 'library', 'OS-windows']
title='os.chmod() does not follow symlinks on Windows'updated_at=<Date2019-04-26.19:53:54.688>user='https://github.com/atsuoishimoto'
Unfortunately, the patch by @atsuoishimoto is too old and cannot be applied to the current code. The difference is so larger, that it is easier to write a new code from scratch than try to resolve conflicts iteratively.
Which I did. My PR uses a different approach. Instead of resolving the symlink path, it opens a handle and changes file attributes by the handle (it is the recommended way). In future it may be possible to implement also os.fchmod().
Now os.chmod() supports follow_symlinks=True on Windows. But by default it does not follow symlinks. Few versions later (in 3.15 or later) we can change the default. It will allow users to use os.lchmod() or os.chmod(follow_symlinks=False) if they need the old behavior, and it will work in several versions.
Activity
atsuoishimoto commentedon Jul 21, 2012
os.chmod() should check symlinks if followsymlinks option is True on Windows.
This is a cause of failure of test case
test.test_shutil.TestShutil.test_copymode_follow_symlinks
(bpo-13837)
atsuoishimoto commentedon Jul 21, 2012
Patch updated. Check symlinks only if supported by platform.
BreamoreBoy commentedon Jul 16, 2014
Can we have a patch review on this please as it's holding up bpo-13837.
pythongh-59616: Support os.chmod(follow_symlinks=True) and os.lchmod(…
pythongh-59616: Support os.chmod(follow_symlinks=True) and os.lchmod(…
serhiy-storchaka commentedon Dec 13, 2023
Unfortunately, the patch by @atsuoishimoto is too old and cannot be applied to the current code. The difference is so larger, that it is easier to write a new code from scratch than try to resolve conflicts iteratively.
Which I did. My PR uses a different approach. Instead of resolving the symlink path, it opens a handle and changes file attributes by the handle (it is the recommended way). In future it may be possible to implement also
os.fchmod().gh-59616: Support os.chmod(follow_symlinks=True) and os.lchmod() on W…
serhiy-storchaka commentedon Dec 14, 2023
Now
os.chmod()supportsfollow_symlinks=Trueon Windows. But by default it does not follow symlinks. Few versions later (in 3.15 or later) we can change the default. It will allow users to useos.lchmod()oros.chmod(follow_symlinks=False)if they need the old behavior, and it will work in several versions.pythongh-59616: Support os.chmod(follow_symlinks=True) and os.lchmod(…
pythongh-59616: Support os.chmod(follow_symlinks=True) and os.lchmod(…
pythongh-59616: Support os.chmod(follow_symlinks=True) and os.lchmod(…