Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-153521: Preserve bytes message sets in imaplib - #153907

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
cuishuang:fix-imaplib-bytes-message-set
Aug 14, 2026
Merged

gh-153521: Preserve bytes message sets in imaplib#153907
serhiy-storchaka merged 1 commit into
python:mainfrom
cuishuang:fix-imaplib-bytes-message-set

Conversation

@cuishuang

Copy link
Copy Markdown
Contributor

_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 bytes and bytearray message sets as ASCII before processing structured sequence sets. It also covers bytes used through the new ?s substitution 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 -j1
  • make patchcheck

No additional NEWS entry is included because this fixes behavior introduced by the unreleased feature tracked by gh-153521, which already has a NEWS entry.

@cuishuang

Copy link
Copy Markdown
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 serhiy-storchaka self-assigned this Aug 14, 2026

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, the analysis is right and the fix is in the correct place.

LGTM. πŸ‘

@serhiy-storchaka
serhiy-storchaka merged commit 0d87a0b into python:main Aug 14, 2026
56 checks passed
mbeijen pushed a commit to mbeijen/cpython that referenced this pull request Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants