gh-84419: Fix the execute permissions in os.stat() on Windows (GH-155… · python/cpython@b7daede · GitHub
Skip to content

Commit b7daede

Browse files
gh-84419: Fix the execute permissions in os.stat() on Windows (GH-155392)
Windows strips trailing dots and spaces from the last component of the path, so os.stat('spam.bat ') opened the same file as os.stat('spam.bat'), but did not set the execute permissions in st_mode, because the extension did not match. They are now ignored, unless the \\?\ prefix disables the path normalization.
1 parent 6b1b90f commit b7daede

3 files changed

Lines changed: 63 additions & 12 deletions

File tree

Lib/test/test_os/test_windows.py

Lines changed: 38 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix :func:`os.stat` on Windows: trailing dots and spaces, which are ignored
2+
by the operating system, are no longer taken into account when the execute
3+
permissions are guessed from the file extension.

Modules/posixmodule.c

Lines changed: 22 additions & 12 deletions

0 commit comments

Comments
 (0)