Match invalid format specifier error messages - #8477
Conversation
Assisted-by: Codex:gpt-5.6-sol
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe change adds a shared VM-aware format-spec parser. Boolean, complex, float, integer, and string formatting methods now use it for parsing and error conversion. ChangesFormat-spec parsing
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] test: cpython/Lib/test/test_format.py dependencies: dependent tests: (no tests depend on format) [x] lib: cpython/Lib/ssl.py dependencies:
dependent tests: (53 tests)
Legend:
|
Summary
This is a follow-up to #8475. RustPython still returned the generic
Invalid format specifiermessage for malformed format specifications, while CPython includes both the original specifier and the runtime object type.Add a VM-level format-spec parsing helper that maps only
InvalidFormatSpecifierto CPython's detailedValueErrormessage. Integer, boolean, float, complex, and string formatting now use the helper, including subclasses whose runtime type names must appear in the error.With the error text matching CPython, this enables the existing
test_better_error_message_format,test_unicode_in_error_message, andtest_specifier_z_errortests without changing their assertions or test data.Tests
cargo run --release -- -m test test_formatcargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi(cd crates/capi && cargo test)— 102 passedcargo clippy --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --all-targetsAI assistance
Codex (GPT-5.6) assisted with comparing CPython and RustPython error behavior, implementing the shared parsing helper, enabling the existing regression tests, running validation, and drafting this PR description. I reviewed the final diff and verified the behavior locally on macOS.
Summary by CodeRabbit