Skip to content

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

Open
spaceone wants to merge 2 commits intopython:mainfrom
spaceone:imaplib-fix-exception-call-with-str
Open

gh-91099: fix[imaplib]: call Exception with string instance#31823
spaceone wants to merge 2 commits intopython:mainfrom
spaceone:imaplib-fix-exception-call-with-str

Conversation

@spaceone
Copy link
Copy Markdown

@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 Standard Library Python modules in the Lib/ directory topic-email labels Feb 26, 2023
@arhadthedev
Copy link
Copy Markdown
Member

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

@spaceone
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

@python/email-team

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

python-cla-bot bot commented Apr 18, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@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
Copy Markdown
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
spaceone and others added 2 commits April 8, 2026 10:03
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stdlib Standard Library Python modules in the Lib/ directory topic-email

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants