Skip to content
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

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

Open
wants to merge 3 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

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
@bedevere-bot

This comment was marked as outdated.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Feb 26, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@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

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.

6 participants