Fix binascii.a2b_uu empty input - #8389
Conversation
Constraint: Match CPython's a2b_uu empty-input behavior. Confidence: high Scope-risk: narrow Directive: Preserve decoding behavior for non-empty UU buffers. Tested: prek run --all-files; test_binascii; cargo fmt --check; cargo clippy -p rustpython-stdlib -- -D warnings; cargo test -p rustpython-stdlib; manual full-suite verification 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 (1)
📝 WalkthroughWalkthrough
ChangesUU decoding validation
Estimated code review effort: 2 (Simple) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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_binascii.py (TODO: 2) dependencies: dependent tests: (95 tests)
Legend:
|
There was a problem hiding this comment.
Pull request overview
This PR aligns RustPython’s binascii.a2b_uu() behavior with CPython by rejecting empty input and raising binascii.Error("Missing length byte"), instead of decoding an empty buffer as a UU length byte.
Changes:
- Added an explicit empty-input guard in
binascii.a2b_uu()that raisesbinascii.Error: Missing length byte. - Removed
@unittest.expectedFailuredecorators fortest_uuandtest_empty_stringnow that the behavior matches CPython.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/stdlib/src/binascii.rs |
Adds the empty-input check to make a2b_uu(b"") raise binascii.Error with the CPython message. |
Lib/test/test_binascii.py |
Enables upstream tests by removing expected-failure markers related to a2b_uu empty-input handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Constraint: Match CPython's a2b_uu empty-input behavior. Confidence: high Scope-risk: narrow Directive: Preserve decoding behavior for non-empty UU buffers. Tested: prek run --all-files; test_binascii; cargo fmt --check; cargo clippy -p rustpython-stdlib -- -D warnings; cargo test -p rustpython-stdlib; manual full-suite verification Assisted-by: Codex:gpt-5.6-sol
Constraint: Match CPython's a2b_uu empty-input behavior. Confidence: high Scope-risk: narrow Directive: Preserve decoding behavior for non-empty UU buffers. Tested: prek run --all-files; test_binascii; cargo fmt --check; cargo clippy -p rustpython-stdlib -- -D warnings; cargo test -p rustpython-stdlib; manual full-suite verification Assisted-by: Codex:gpt-5.6-sol
Summary
Make
binascii.a2b_uu(b\"\")raisebinascii.Error, matching CPython.Previously, empty input was treated as a UU length byte and returned 32 NUL
bytes. It is now rejected before decoding with
binascii.Error: Missing length byte.Testing
cargo run --release -- -m test test_binasciiprek run --all-filescargo fmt --checkcargo clippy -p rustpython-stdlib -- -D warningscargo test -p rustpython-stdlibSummary by CodeRabbit