Repository navigation
Return EBADF for negative stat file descriptors - #9008
Conversation
Return EBADF for negative ordinary descriptors before calling rustix, avoiding debug-build assertions on canonical invalid-fd tests. Keep directory-fd sentinel and absolute-path handling unchanged. Assisted-by: Codex:model-version-unavailable
Exercise ordinary negative descriptors including values accepted by rustix as directory sentinels, without changing canonical tests or directory-fd parsing. Assisted-by: Codex:model-version-unavailable
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
do not add python test code in rust file
Preserve the original Unix RustPython-only coverage and every regression assertion while removing the redundant Rust interpreter wrapper. CPython uses -1 as a path sentinel, so keep this regression scoped to its original runtime. Assisted-by: Codex:model-version-unavailable
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3052bd9c7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for stat in (os.stat, os.fstat): | ||
| for fd in (-1, -5, -9, -100, -(2**31)): |
There was a problem hiding this comment.
Remove the prohibited test logic
These added loops introduce new test logic and data in extra_tests/snippets/stdlib_os.py, but the root test-code policy says not to modify test assertions, logic, or data and limits acceptable test-file changes to expected-failure decorator updates. Remove this regression-test addition while retaining the Rust fix so the change complies with the repository policy.
AGENTS.md reference: AGENTS.md:L275-L279
Useful? React with 👍 / 👎.
Summary
Extract the negative-descriptor
fstatguard from #8954 for the Python 3.14 main branch.os.stat(-5)andos.fstat(-5)can reach rustix with an invalid ordinary descriptor and panic in debug builds. ReturnEBADFat the shared non-Windowsfstatboundary before calling rustix. Add an interpreter regression covering several negative values, including numbers used as directory-descriptor sentinels elsewhere.This is a four-line implementation change plus one new Rust integration test. Directory-fd parsing and canonical Python tests are unchanged. It is independent of the closerange/termination fixes in #9006.
Validation
Fresh main-based validation on Linux, with source/runtime identity checked:
EBADFfor the tested negative descriptors and preserve valid/closed-fd behavior and six existing supported directory-fd cases.test_osfstat selection also passed throughcargo run.The initial broader
FileTestsrun aborts in the separatetest_closerangecase. The same case aborts on unpatched main; #9006 addresses it. That failed result is retained, and the successful selection excludes that case without changing tests or adding skips. Full localtest_osremains unrun because its asyncio setup requires the sandbox-denied AF_UNIX socketpair. Hosted tests remain enabled; cross-platform CI is pending.The runtime is main's Python 3.14.alpha. Any CPython comparison used the available 3.15.0rc3 interpreter, not a CPython 3.14 build.
AI assistance
Codex assisted with implementation, extraction, source review, regression tests, and automated validation. The original implementation authorship and
Assisted-bytrailer are preserved; the regression commit also includes its disclosure.