Fix malformed Unicode error constructors - #8497
Conversation
Replace message-only Unicode decode and encode errors with fully initialized exceptions, preserve source objects and failure ranges, and remove the obsolete constructors. Assisted-by: Codex:gpt-5
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Assisted-by: Codex:gpt-5
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/codecs.py dependencies:
dependent tests: (161 tests)
Legend:
|
Fixes #8352.
Summary
UnicodeDecodeErrorandUnicodeEncodeErrorconstruction with fully initialized exceptionsnew_unicode_decode_errorRoot cause and impact
The old macro-generated helpers bypassed Unicode error initialization and created one-argument exceptions. Those exceptions had no
encoding,object,start,end, orreasonattributes, and their string representation could be empty. All affected paths now produce structurally valid exceptions that error handlers and user code can inspect.Validation
cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capicargo check -p rustpython-stdlib --features tkintercargo checkfromcrates/capimbcs/oem,ntpath decoding, and the original CSV reproductionrustfmt,cspell, merge-conflict and patch checks)The standalone C-API
cargo testreaches the link step but cannot run in this checkout because its Windows configuration references the unavailable placeholder librarypythonXY.lib; itscargo checkpasses.AI assistance
Implementation and validation were assisted by Codex (GPT-5) and reviewed interactively by the contributor.