diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2022-12-02 08:37:54 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2023-05-25 10:56:30 +0200 |
commit | fc5ec40e057df7b848aeac4cb821c981a1f3fb49 (patch) | |
tree | 73be72e9e02a7f126bf0b48000b10eb19128a2c2 /news2mail.py | |
parent | 53f97b330e7b0cdcc07e57aad06fd45c8a0f1e5d (diff) | |
download | pyg-fc5ec40e057df7b848aeac4cb821c981a1f3fb49.tar.gz |
New generation of email.message_from* methods could use better policy.
The email module changed a lot with more recent versions of
Python (ehm, more recent, >= 3.3 ;)), and it uses per default
old-compatible-with-Python 2 policy which is ASCII-based. The
policy which is called default is not used per default [sic] and
it is much better suited for UTF-8 world.
Diffstat (limited to 'news2mail.py')
-rw-r--r-- | news2mail.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/news2mail.py b/news2mail.py index 624290f..a92c7e5 100644 --- a/news2mail.py +++ b/news2mail.py @@ -26,6 +26,7 @@ from __future__ import absolute_import from __future__ import print_function from collections import OrderedDict import email +import email.policy import smtplib from socket import gethostbyaddr, gethostname import sys @@ -52,7 +53,8 @@ class news2mail(object): self.heads_dict = {} self.article, self.headers, self.body = [], [], [] - self.message = self.__addheads(email.message_from_binary_file(sys.stdin.buffer)) + self.message = self.__addheads( + email.message_from_file(sys.stdin, policy=email.policy.default)) def __addheads(self, msg): """add new header like X-Gateway: Received: |