FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-144050: Fix stat.filemode pure Python file type detection by VanshAgarwal24036 · Pull Request #144059 · python/cpython · GitHub

Repository navigation

gh-144050: Fix stat.filemode pure Python file type detection - #144059

Merged
serhiy-storchaka merged 4 commits into
python:mainfrom
VanshAgarwal24036:gh-144050
Jan 20, 2026
Merged

serhiy-storchaka merged 4 commits into
python:mainfrom
VanshAgarwal24036:gh-144050

Conversation

VanshAgarwal24036 commented Jan 20, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

This PR fixes a discrepancy between the C and pure Python implementations
of stat.filemode.

The pure Python implementation could misclassify arbitrary bit patterns
(e.g. 32767) as block devices. File type detection now correctly uses
(mode & S_IFMT) for file types, matching the C implementation.

A regression test is added to prevent this issue from recurring.

Fixes #144050

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please add a NEWS entry.

Comment thread Lib/test/test_stat.py Outdated
Comment thread Lib/stat.py
…kKFbF.rst

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. 👍

serhiy-storchaka merged commit fe62926 into python:main Jan 20, 2026
51 checks passed
VanshAgarwal24036 deleted the gh-144050 branch January 20, 2026 12:11
serhiy-storchaka added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Jan 20, 2026

Copy link
Copy Markdown

Thanks @VanshAgarwal24036 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

Copy link
Copy Markdown

Thanks @VanshAgarwal24036 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 20, 2026
…ythonGH-144059)

(cherry picked from commit fe62926)

Co-authored-by: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 20, 2026
…ythonGH-144059)

(cherry picked from commit fe62926)

Co-authored-by: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com>

bedevere-app Bot commented Jan 20, 2026

Copy link
Copy Markdown

GH-144073 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jan 20, 2026

bedevere-app Bot commented Jan 20, 2026

Copy link
Copy Markdown

GH-144074 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jan 20, 2026
serhiy-storchaka pushed a commit that referenced this pull request Jan 20, 2026
…H-144059) (GH-144074)

(cherry picked from commit fe62926)

Co-authored-by: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com>
serhiy-storchaka pushed a commit that referenced this pull request Jan 20, 2026
…H-144059) (GH-144073)

(cherry picked from commit fe62926)

Co-authored-by: VanshAgarwal24036 <148854295+VanshAgarwal24036@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discrepancy between stat.filemode's C and Python implementation

2 participants


Back | FazBrowse Home | New Git URL