Skip to content

Commit

Permalink
Replaced Message.get_charset() with Message.get_content_charset():
Browse files Browse the repository at this point in the history
Fixes the bug described here: repoze#41

Rationale:

get_content_charset() has been there in email.message.Message for a long
time now, returning the charset of the body of the Message (which is what we
are looking for there).

get_charset() has been deprecated for some time now, returns None by default
(even if a charset is set in the Content-Type header).

There are some other ways to retrieve the charset (get_params(),
get_param('charset'), message['Content-Type'].params) but get_content_charset()
is the only one that exists through all existing python versions, and it is
there even in the new email.message.EmailMessage class.
  • Loading branch information
WuShell committed Feb 20, 2019
1 parent df004f8 commit 06b8ec9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion repoze/sendmail/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def cleanup_message(message,

payload = message.get_payload()
if payload and isinstance(payload, text_type):
charset = message.get_charset()
charset = message.get_content_charset()
if not charset:
charset, encoded = best_charset(payload)
message.set_payload(payload, charset=charset)
Expand Down

0 comments on commit 06b8ec9

Please sign in to comment.