8000 Fix unicode decode bug on surrogate error mode by arihant2math · Pull Request #5546 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Comments

Fix unicode decode bug on surrogate error mode#5546

Merged
youknowone merged 2 commits intoRustPython:mainfrom
arihant2math:codecs-fix
Feb 23, 2025
Merged

Fix unicode decode bug on surrogate error mode#5546
youknowone merged 2 commits intoRustPython:mainfrom
arihant2math:codecs-fix

Conversation

@arihant2math
Copy link
Contributor
@arihant2math arihant2math commented Feb 23, 2025

Fixes #5542; error introduced by #5502. Adds some debug assertions that are also in cpython.
This will help allow test_argparse to work for windows.

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
// let the codec call us again.
let p = &s.as_bytes()[range.start..];
if p.len().saturating_sub(range.start) >= byte_length {
if p.len().overflowing_sub(range.start).0 >= byte_length {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if p.len().overflowing_sub(range.start).0 >= byte_length {
if p.len() >= range.start + byte_length {

does this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for confirming

@youknowone youknowone merged commit 429754f into RustPython:main Feb 23, 2025
22 checks passed
@arihant2math arihant2math deleted the codecs-fix branch February 25, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bytes.decode doesn't honor error mode

2 participants

0