Skip to content

Commit 06b8ec9

Browse files
committed
Replaced Message.get_charset() with Message.get_content_charset():
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.
1 parent df004f8 commit 06b8ec9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

repoze/sendmail/encoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def cleanup_message(message,
7171

7272
payload = message.get_payload()
7373
if payload and isinstance(payload, text_type):
74-
charset = message.get_charset()
74+
charset = message.get_content_charset()
7575
if not charset:
7676
charset, encoded = best_charset(payload)
7777
message.set_payload(payload, charset=charset)

0 commit comments

Comments
 (0)