Repository navigation
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
IncrementalNewlineDecoder(translate), its decode(final), FileIO(closefd), os.set_blocking and os.dup2(inheritable) accepted only int instances and raised TypeError for any other object. Bind them as ArgIntoBool so every object is converted by its truth value. Assisted-by: Claude Code:claude-fable-5-2
26f81de to
dc38dc6
Compare
Codex Review Summary: ✅ CompletedThis 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: dc38dc623b
ℹ️ 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".
| #[pyarg(any, default = true)] | ||
| inheritable: bool, | ||
| #[pyarg(any, default = ArgIntoBool::TRUE)] | ||
| inheritable: ArgIntoBool, |
There was a problem hiding this comment.
Keep
fd2 non-owning during truth conversion
On POSIX, an int subclass whose __bool__ closes the destination descriptor and raises now runs that callback after Dup2Args has wrapped fd2 in an OwnedFd. The generated FromArgs then returns through ? and drops the partially initialized field, double-closing the descriptor and aborting debug builds with an I/O-safety violation instead of propagating the Python exception. The old integer-only converter never invoked this callback. Keep fd2 raw/non-owning until the flag conversion has succeeded.
Useful? React with 👍 / 👎.
Summary
io.IncrementalNewlineDecoder(translate), itsdecode(final),io.FileIO(closefd),os.set_blocking(blocking)andos.dup2(inheritable)bind their flag as a Rustbool, whose conversion accepts onlyintinstances. CPython declares all five as Argument Clinicbool, which callsPyObject_IsTrue(for exampleclosefd), so any object is accepted and an exception from__bool__propagates.AS-IS
TO-BE
(matching CPython 3.15.2)
Changes
translate,finalandclosefdasArgIntoBoolincrates/vm/src/stdlib/_io.rs, andblockingandinheritableincrates/vm/src/stdlib/posix.rs. Signatures are unchanged.extra_tests/snippets/stdlib_io.pyandextra_tests/snippets/stdlib_os.py.os(follow_symlinks,effective_ids), theclosefdofopen(), whoseOpenArgsis also built from Rust incrates/capi, and what I could not build: the Windows versions innt.rsand_WindowsConsoleIO, and the positionaltarget_is_directoryofos.symlink, which is only read innt.rs.Test plan
Built and run on macOS aarch64 against upstream/main 7abccf0, using the CI feature set
--no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,doc,ucd_3_2_0, plusthreading, compared with CPython 3.15.2.stdlib_io.pyandstdlib_os.pyfail on an unpatched build of that commit (TypeError: Expected type bool, not NoneType) and pass with the patch and under CPython 3.15.2.__bool__raises, astrand0give the same result as CPython 3.15.2 fortranslate,closefd,blockingandinheritable.rustpython -m test test_io test_os: 1,592 run, 202 skipped, all pass, as on the unpatched build.cargo fmt --checkclean,cargo clippy -p rustpython-vm -p rustpython-stdlib --all-targetsreports nothing new, and the pre-commit hooks other thancspellandprettierpass on the changed files.I used Claude Code (claude-fable-5-2) to draft the analysis, the patch and this description; Claude Code ran the commands above; I reviewed the diff and their output.
Summary by CodeRabbit
Noneand strings.Noneand truthy strings.