-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-46943: fix[imaplib]: call Exception with string instance #31722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
56a9251
to
e1820d7
Compare
Judging from the commits pulled in, this PR branch was likely branched off of 3.10 or branch thereof. Please redo starting with 3.11 (main). Check the commit and diff list before hitting the green make-PR button. Also, is bpo not working to make a proper issue? |
Traceback (most recent call last): File "29_mail_related_modifications_of_user_objects", line 29, in check_login_lookup imap.log_in(mail, password) File "/usr/share/ucs-test/40_mail/essential/mailclient.py", line 54, in log_in self.login(usermail, 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): File "29_mail_related_modifications_of_user_objects", line 274, in <module> main() File "29_mail_related_modifications_of_user_objects", line 93, in main check_login_lookup(host, usermail, password, False) File "29_mail_related_modifications_of_user_objects", line 37, in check_login_lookup if any([msg in str(ex) for msg in auth_errors]): File "29_mail_related_modifications_of_user_objects", line 37, in <listcomp> if any([msg in str(ex) for msg in auth_errors]): BytesWarning: str() on a bytes instance → python/cpython#31722 Traceback (most recent call last): File "11mount-home", line 65, in <module> print(stdout, ret) BytesWarning: str() on a bytes instance Traceback (most recent call last): File "00check_forward_secrecy", line 88, in <module> check_pfs_cipher() File "00check_forward_secrecy", line 45, in check_pfs_cipher openssl_out = run_openssl().decode('UTF-8') File "00check_forward_secrecy", line 73, in run_openssl print("Openssl client STDOUT:\n", stdout) BytesWarning: str() on a bytes instance Traceback (most recent call last): File "47domain_user_lockout", line 185, in <module> check_error_present_in_output(stdout, stderr) File "47domain_user_lockout", line 147, in check_error_present_in_output if 'NT_STATUS_ACCOUNT_LOCKED_OUT' not in (stdout + stderr).decode('UTF-8'): AttributeError: 'str' object has no attribute 'decode'
@terryjreedy The branch was already rebased onto main before you closed the MR. Can you reopen it again? |
Traceback (most recent call last): File "29_mail_related_modifications_of_user_objects", line 29, in check_login_lookup imap.log_in(mail, password) File "/usr/share/ucs-test/40_mail/essential/mailclient.py", line 54, in log_in self.login(usermail, 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): File "29_mail_related_modifications_of_user_objects", line 274, in <module> main() File "29_mail_related_modifications_of_user_objects", line 93, in main check_login_lookup(host, usermail, password, False) File "29_mail_related_modifications_of_user_objects", line 37, in check_login_lookup if any([msg in str(ex) for msg in auth_errors]): File "29_mail_related_modifications_of_user_objects", line 37, in <listcomp> if any([msg in str(ex) for msg in auth_errors]): BytesWarning: str() on a bytes instance → python/cpython#31722 Traceback (most recent call last): File "11mount-home", line 65, in <module> print(stdout, ret) BytesWarning: str() on a bytes instance Traceback (most recent call last): File "00check_forward_secrecy", line 88, in <module> check_pfs_cipher() File "00check_forward_secrecy", line 45, in check_pfs_cipher openssl_out = run_openssl().decode('UTF-8') File "00check_forward_secrecy", line 73, in run_openssl print("Openssl client STDOUT:\n", stdout) BytesWarning: str() on a bytes instance Traceback (most recent call last): File "47domain_user_lockout", line 185, in <module> check_error_present_in_output(stdout, stderr) File "47domain_user_lockout", line 147, in check_error_present_in_output if 'NT_STATUS_ACCOUNT_LOCKED_OUT' not in (stdout + stderr).decode('UTF-8'): AttributeError: 'str' object has no attribute 'decode'
Created upstream bug repport: https://bugs.python.org/issue46943 |
Adjust the behavior of
login
similar toauthenticate()
whereself.error
is called with astr
instance.Especially for Python3 with strict bytes mode (-bb) this is helpful and prevents:
https://bugs.python.org/issue46943