Skip to content

gh-91099: fix[imaplib]: call Exception with string instance #31823

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

spaceone
Copy link

@spaceone spaceone commented Mar 11, 2022

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

https://bugs.python.org/issue46943

@bedevere-bot

This comment was marked as outdated.

@arhadthedev arhadthedev changed the title bpo-46943: fix[imaplib]: call Exception with string instance gh-91099: fix[imaplib]: call Exception with string instance Feb 26, 2023
@arhadthedev arhadthedev added stdlib Python modules in the Lib dir topic-email labels Feb 26, 2023
@arhadthedev
Copy link
Member

@spaceone Could you sign the new CLA by clicking not signed button in the cpython-cla-bot's message, please?

@spaceone
Copy link
Author

@spaceone Could you sign the new CLA by clicking not signed button in the cpython-cla-bot's message, please?

I tried but get a white screen with Internal Server Error. Will retry later in the evening with another browser.

@arhadthedev
Copy link
Member

arhadthedev commented Feb 26, 2023

No worries, your click was accepted. The displayed error is a known although yet untracked problem.

@arhadthedev
Copy link
Member

@python/email-team

@python python deleted a comment Apr 7, 2025
@python-cla-bot
Copy link

python-cla-bot bot commented Apr 18, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

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
@spaceone spaceone force-pushed the imaplib-fix-exception-call-with-str branch from 300787f to 4b7fa1c Compare April 18, 2025 09:56
@spaceone
Copy link
Author

rebased :-)
+ 300787ffd7b...4b7fa1c8e42 imaplib-fix-exception-call-with-str -> imaplib-fix-exception-call-with-str (forced update)

@spaceone spaceone force-pushed the imaplib-fix-exception-call-with-str branch from 4b7fa1c to 0a9dc07 Compare April 18, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review stdlib Python modules in the Lib dir topic-email
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants