serhiy-storchaka ยท GitHub

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

Read the original on github.com โ†—