Skip to content

Commit e1820d7

Browse files
committed
bpo-XXXX: fix[imaplib]: call Exception with string instance
Adjust the behavior 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
1 parent 5c06dba commit e1820d7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Lib/imaplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def login(self, user, password):
609609
"""
610610
typ, dat = self._simple_command('LOGIN', user, self._quote(password))
611611
if typ != 'OK':
612-
raise self.error(dat[-1])
612+
raise self.error(dat[-1].decode('UTF-8', 'replace'))
613613
self.state = 'AUTH'
614614
return typ, dat
615615

0 commit comments

Comments
 (0)