Skip to content

gh-153417: Fix BytesWarning in imaplib error messages for bytes arguments#153423

Merged
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:imaplib-error-byteswarning
Jul 9, 2026
Merged

gh-153417: Fix BytesWarning in imaplib error messages for bytes arguments#153423
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:imaplib-error-byteswarning

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

IMAP4.select() and IMAP4.uid() formatted the mailbox and command argument with %s in their error messages. Both arguments accept bytes, so under -bb formatting a bytes value raised BytesWarning and masked the real error. This changes both to %r, which is safe for bytes and also quotes the value.

… arguments

IMAP4.select() and IMAP4.uid() formatted the mailbox and command argument
with %s in their error messages, which raised BytesWarning under -bb when the
argument was bytes and masked the real error.  Use %r instead, which is safe
for bytes and also quotes the value.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka requested a review from a team as a code owner July 9, 2026 12:36
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 9, 2026
There is no -bb option target (only .. option:: -b), so use :option:`!-bb`
to keep the literal text without a dangling cross-reference.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) July 9, 2026 13:18
@serhiy-storchaka serhiy-storchaka merged commit 11f1b70 into python:main Jul 9, 2026
54 of 55 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 9, 2026

Copy link
Copy Markdown

GH-153430 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 9, 2026
@bedevere-app

bedevere-app Bot commented Jul 9, 2026

Copy link
Copy Markdown

GH-153431 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 9, 2026
@bedevere-app

bedevere-app Bot commented Jul 9, 2026

Copy link
Copy Markdown

GH-153432 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jul 9, 2026
serhiy-storchaka added a commit that referenced this pull request Jul 9, 2026
…s arguments (GH-153423) (GH-153432)

IMAP4.select() and IMAP4.uid() formatted the mailbox and command argument
with %s in their error messages, which raised BytesWarning under -bb when the
argument was bytes and masked the real error.  Use %r instead, which is safe
for bytes and also quotes the value.
(cherry picked from commit 11f1b70)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 9, 2026
…s arguments (GH-153423) (GH-153430)

IMAP4.select() and IMAP4.uid() formatted the mailbox and command argument
with %s in their error messages, which raised BytesWarning under -bb when the
argument was bytes and masked the real error.  Use %r instead, which is safe
for bytes and also quotes the value.
(cherry picked from commit 11f1b70)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 9, 2026
…s arguments (GH-153423) (GH-153431)

IMAP4.select() and IMAP4.uid() formatted the mailbox and command argument
with %s in their error messages, which raised BytesWarning under -bb when the
argument was bytes and masked the real error.  Use %r instead, which is safe
for bytes and also quotes the value.
(cherry picked from commit 11f1b70)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka deleted the imaplib-error-byteswarning branch July 9, 2026 15:21
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.

2 participants