gh-153521: Preserve bytes message sets in imaplib - #153907
Merged
serhiy-storchaka merged 1 commit intoAug 14, 2026
Merged
Conversation
Signed-off-by: cuishuang <[email protected]>
Contributor
Author
|
@serhiy-storchaka, would you mind taking a look at this? This fixes a backward-compatibility regression in the structured message-set support from #153522. Thanks! |
serhiy-storchaka
approved these changes
Aug 14, 2026
serhiy-storchaka
left a comment
Member
There was a problem hiding this comment.
Thanks, the analysis is right and the fix is in the correct place.
LGTM. π
mbeijen
pushed a commit
to mbeijen/cpython
that referenced
this pull request
Aug 14, 2026
) Signed-off-by: cuishuang <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_format_sequence_set()treated every non-integer, non-string argument as a structured sequence. As a result, a preformatted bytes message set was iterated byte by byte. For example,b"2:4"was sent on the wire as"50,58,52".Before structured message-set support was added, bytes arguments were passed through unchanged. This therefore caused a backward compatibility regression.
This change decodes preformatted
bytesandbytearraymessage sets as ASCII before processing structured sequence sets. It also covers bytes used through the new?ssubstitution mechanism.The tests include an end-to-end FETCH case that verifies the server receives
2:4, rather than the numeric values of the individual bytes.Tests:
./python.exe -m test test_imaplib -j1make patchcheckNo additional NEWS entry is included because this fixes behavior introduced by the unreleased feature tracked by gh-153521, which already has a NEWS entry.