Skip to content

Fix bare except clause in flanker/mime/message/part.py#273

Open
koteshyelamati wants to merge 1 commit into
mailgun:masterfrom
koteshyelamati:master
Open

Fix bare except clause in flanker/mime/message/part.py#273
koteshyelamati wants to merge 1 commit into
mailgun:masterfrom
koteshyelamati:master

Conversation

@koteshyelamati

Copy link
Copy Markdown

Replace bare except: with except (UnicodeEncodeError, LookupError): in the charset encoding fallback.

The function tries to encode text with a preferred charset and falls back to UTF-8 on failure. Bare except: catches BaseException, but the only failures expected here are UnicodeEncodeError (the charset can't represent the text) and LookupError (unknown charset name). Using specific exception types prevents accidental suppression of KeyboardInterrupt or SystemExit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant