Two imaplib error messages format a user-supplied argument with %s:
IMAP4.select()โ the "not writable" error for a read-only mailbox:raise self.readonly('%s is not writable' % mailbox)
IMAP4.uid()โ the unknown-command error:raise self.error("Unknown IMAP4 UID command: %s" % command)
Both mailbox and command accept bytes (mailbox names are commonly bytes, e.g. as returned by list()). When the argument is bytes, formatting it with %s calls str(bytes), which raises BytesWarning under python -bb, masking the real error.
Linked PRs
- gh-153417: Fix BytesWarning in imaplib error messages for bytes arguments #153423
- [3.15] gh-153417: Fix BytesWarning in imaplib error messages for bytes arguments (GH-153423) #153430
- [3.14] gh-153417: Fix BytesWarning in imaplib error messages for bytes arguments (GH-153423) #153431
- [3.13] gh-153417: Fix BytesWarning in imaplib error messages for bytes arguments (GH-153423) #153432