Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.14] gh-144050: Fix stat.filemode pure Python file type detection (GH-144059)#144073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletionsLib/stat.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,9 +166,14 @@ def filemode(mode):
perm = []
for index, table in enumerate(_filemode_table):
for bit, char in table:
if mode & bit == bit:
perm.append(char)
break
if index == 0:
if S_IFMT(mode) == bit:
perm.append(char)
break
else:
if mode & bit == bit:
perm.append(char)
break
else:
if index == 0:
# Unknown filetype
Expand Down
5 changes: 5 additions & 0 deletionsLib/test/test_stat.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -163,6 +163,11 @@ def test_mode(self):
self.statmod.S_IFREG)
self.assertEqual(self.statmod.S_IMODE(st_mode), 0o666)

def test_filemode_does_not_misclassify_random_bits(self):
# gh-144050 regression test
self.assertEqual(self.statmod.filemode(0o77777)[0], "?")
self.assertEqual(self.statmod.filemode(0o177777)[0], "?")

@os_helper.skip_unless_working_chmod
def test_directory(self):
os.mkdir(TESTFN)
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
Fix :func:`stat.filemode` in the pure-Python implementation to avoid misclassifying
invalid mode values as block devices.
Loading

[8]ページ先頭

©2009-2026 Movatter.jp