Repository navigation
Include name and path in ImportError repr - #9247
Conversation
Extract the independent Python 3.15 ImportError representation change from the upgrade work. Preserve BaseException positional arguments and include explicitly present name/path attributes for ImportError and ModuleNotFoundError. AI assistance: OpenAI Codex prepared the extraction and validation. Model version is not exposed in this session. Assisted-by: Codex:unknown (model version not exposed)
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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78bdb6f52e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
| result.push_str(name); | ||
| result.push('='); | ||
| result.push_str(&value.repr(vm)?.to_string_lossy()); |
There was a problem hiding this comment.
Preserve surrogates in keyword field reprs
When a name or path object has a legal __repr__ returning a string with an unpaired surrogate (for example '\ud800'), PyImportError::repr_str replaces that surrogate with U+FFFD before constructing the Python string. Python str preserves such code points, so repr(ImportError(name=obj)) is corrupted; append the returned PyStr's WTF-8 data (for example via repr_wtf8) instead of using the lossy UTF-8 conversion.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed: a custom repr returning U+D800 was converted to U+FFFD for name/path. Since #9247 merged while validation was in progress, the correction is now in #9252: use repr_wtf8 and push_wtf8 throughout. The four class/field combinations pass against pinned CPython and the newly built candidate, along with the six canonical ImportError methods and the documented native gates. No Lib or repository test changes.
Summary
Independent native-only extraction from #8954: include explicitly present
nameandpathattributes inImportError.__repr__, including explicitNone. Preserve positional arguments and the dynamic exception class name, soModuleNotFoundErrorinherits the new representation.Only
crates/vm/src/exceptions.rschanges (+30/-2). No Lib refresh, dependency change, or copied regression snippet.Validation
Tested on main
b4a1ad232f8eb68523ce687183ce08958d4b6744plus this exact native delta:ImportErrorTestsmethods fromd220409a13b77de7a6c30abe16ea90db01528edcpassed in both the new candidate and pinned CPython: attributes, reset attributes, non-string argument, copy/pickle, repr, and ModuleNotFoundError repr after failed import. The historical RustPython baseline passed the first four and failed precisely the two repr methods.--all-targetspassed without warnings.Aggregate native gates used CI's
CARGO_PROFILE_DEV_DEBUG=0andCARGO_PROFILE_TEST_DEBUG=0, one build job, incremental disabled and serial test dispatch. Repository optimization levels, debug assertions and overflow checks were preserved. Workspace excludes wasm, venvlauncher and CAPI; CAPI commands ran separately from its own directory.Focused Python validation used a source-hash-checked class-only AST harness preserving the canonical method bodies, with
-B -S, normal import hooks and a 30-second bound. The fulltest_exceptionsmodule/release-mode suite was not run; unrelated memory/crash and process fixtures were outside the reviewed execution scope. No test assertions or library sources were changed.AI assistance: OpenAI Codex prepared the extraction, source review, validation and PR text. The model version is not exposed in this session; the commit discloses that limitation rather than guessing a version.
Summary by CodeRabbit