Visitar URL original
gh-158998: Fix os.statx() ignoring follow_symlinks=False by jjhelmus · Pull Request #158999 · python/cpython · GitHub
Skip to content

gh-158998: Fix os.statx() ignoring follow_symlinks=False - #158999

Open
jjhelmus wants to merge 1 commit into
python:mainfrom
jjhelmus:statx-follow-symlinks
Open

jjhelmus wants to merge 1 commit into
python:mainfrom
jjhelmus:statx-follow-symlinks

Conversation

@jjhelmus

@jjhelmus jjhelmus commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Set AT_SYMLINK_NOFOLLOW to prevent statx from following symlinks when follow_symlinks=False is passed to os.statx.

@jjhelmus

jjhelmus commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Let me know if this change meet the criteria for needing tests or a NEWS item. I can add both if needed.

@cmaloney

cmaloney commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

This will need both NEWS and a test (changes visible behavior of a feature that has been in a release). Pinged the contributor who added statx to hopefully review (haven’t reviewed the implementation myself yet)

@jbosboom

jbosboom commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

The fix looks obviously correct. (Whoops!)

The tests should go in test_os.StatAttributeTests. Change check_statx_attributes to accept a follow_symlinks kwarg and pass it to the os.stat and os.statx calls, then add new test methods like test_statx_attributes that create a proper/broken symlink and pass follow_symlinks=False/True (four cases; can be four methods or one method with four subtests).

Ping me again for review when you've written the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants