Skip to content

imaplib: select() and uid() error messages raise BytesWarning for a bytes argument #153417

Description

@serhiy-storchaka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions