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
Path.chmod() silently fails on Windows when archive bit is cleared and follow_symlinks=True #140774
Root-cause note for triage: although reported via Path.chmod(), the bug is in win32_hchmod() (Modules/posixmodule.c, introduced in GH-113049 / GH-113192), affecting os.chmod(..., follow_symlinks=True), os.chmod(fd, ...), os.fchmod(), and Path.chmod() alike (os.chmod() on Windows defaults to follow_symlinks=False, which goes through SetFileAttributesW() instead).
Newly created files on NTFS carry FILE_ATTRIBUTE_ARCHIVE (0x20), so clearing FILE_ATTRIBUTE_READONLY (0x01) normally leaves info.FileAttributes != 0. When READONLY is the sole attribute (e.g. after attrib -a +r), info.FileAttributes &= ~FILE_ATTRIBUTE_READONLY yields 0, which FILE_BASIC_INFO documents as leaving attributes unchanged rather than clearing them; FILE_ATTRIBUTE_NORMAL must be passed instead. Fix and regression tests are in #154852.
Activity
pythongh-140774: Fix pathlib.Path.chmod not handling the Archive bit …
Fix pythongh-140774: os.chmod fails to clear Read-Only if Archive bit…
Merge remote-tracking branch 'upstream/main' into pythongh-140774-hch…
pythongh-140774: Set SetFileAttributesW argtypes and cover fd/Path.chmod
yhay81 commentedon Nov 12, 2026
Root-cause note for triage: although reported via
Path.chmod(), the bug is inwin32_hchmod()(Modules/posixmodule.c, introduced in GH-113049 / GH-113192), affectingos.chmod(..., follow_symlinks=True),os.chmod(fd, ...),os.fchmod(), andPath.chmod()alike (os.chmod()on Windows defaults tofollow_symlinks=False, which goes throughSetFileAttributesW()instead).Newly created files on NTFS carry
FILE_ATTRIBUTE_ARCHIVE(0x20), so clearingFILE_ATTRIBUTE_READONLY(0x01) normally leavesinfo.FileAttributes != 0. WhenREADONLYis the sole attribute (e.g. afterattrib -a +r),info.FileAttributes &= ~FILE_ATTRIBUTE_READONLYyields0, whichFILE_BASIC_INFOdocuments as leaving attributes unchanged rather than clearing them;FILE_ATTRIBUTE_NORMALmust be passed instead. Fix and regression tests are in #154852.pythongh-140774: Remove redundant Path.chmod() test from Win32ChmodTests
gh-140774: Fix clearing the read-only file attribute on Windows (GH-1…
[3.14] gh-140774: Fix clearing the read-only file attribute on Windows (
[3.15] gh-140774: Fix clearing the read-only file attribute on Windows (