Skip to content

gh-83714: Use statx on Linux 4.11 and later in os.stat#136334

Closed
jbosboom wants to merge 19 commits into
python:mainfrom
jbosboom:statx
Closed

gh-83714: Use statx on Linux 4.11 and later in os.stat#136334
jbosboom wants to merge 19 commits into
python:mainfrom
jbosboom:statx

Conversation

@jbosboom

@jbosboom jbosboom commented Jul 6, 2025

Copy link
Copy Markdown
Contributor

I've posted some questions in gh-83714. For now, this PR should be considered earnest effort (in the sense of earnest money). It will change based on the answers to the questions in the issue. It needs tests for the new features and the fallback that are not obvious to implement. I need guidance as to when it should strictly conform to PEP 7 and when it should match the surrounding code style (especially with regards to brace placement). But it should demonstrate I'm willing and able.

The libc statx wrapper is required at build time, but weakly linked. There is no configure test; we just look for STATX_BASIC_STATS being defined by sys/stat.h. posix_do_stat will fall back to calling stat if statx is not available at runtime due to an old libc or an old kernel. The fallback variable statx_works is based on dup3_works, for the thread-safety of which see @ericsnowcurrently's comment. The values are (to me) nonobvious: -1 means statx has never failed, 0 means its first failure was ENOSYS and 1 means its first failure was something other than ENOSYS.

This PR is not directly based on gh-19125, but was greatly informed by it, and I'd be happy to give Co-authored-by and/or blurb credit to @ntninja.


📚 Documentation preview 📚: https://cpython-previews--136334.org.readthedocs.build/

Loading
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.

7 participants