[New-bugs-announce] [issue46943] fix[imaplib]: call Exception with string instance

SpaceOne report at bugs.python.org
Mon Mar 7 06:30:04 EST 2022


New submission from SpaceOne <python at florianbest.de>:

imaplib raises an Exception with a bytes instance once (in login()) - all other places str instances are raised.

Adjust the behavior of login() similar to authenticate() where self.error is called with a str instance.

Especially for Python3 with strict bytes mode (-bb) this is helpful and prevents:

    Traceback (most recent call last):
      in "<stdin>"
        self.login(email, password)
      File "/usr/lib/python3.7/imaplib.py", line 598, in login
        raise self.error(dat[-1])
    imaplib.error: <exception str() failed>
    
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      in "<stdin>"
        str(exc)
    BytesWarning: str() on a bytes instance

----------
components: Library (Lib)
messages: 414657
nosy: spaceone
priority: normal
severity: normal
status: open
title: fix[imaplib]: call Exception with string instance
versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46943>
_______________________________________


More information about the New-bugs-announce mailing list