diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-11-28 08:24:10 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-11-28 08:27:13 +0200 |
commit | ca0dcfca2ad25541b9553d7110090f9ba49092d8 (patch) | |
tree | 5453715c8331388866cbe112e4bf60425015885a | |
parent | 48df8095d4e50a3c98a14939ed046f2e100615f7 (diff) |
Switch to new parser API
While email.message_from_binary_file() isn't documented as deprecated,
it returns an email.message.Message object which is documented as
legacy. Switch to email.parser.BytesParser() to obtain an
email.message.EmailMessage() object instead.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rwxr-xr-x | patch-save.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/patch-save.py b/patch-save.py index 1c0516f..a9b9a3c 100755 --- a/patch-save.py +++ b/patch-save.py @@ -18,6 +18,8 @@ # import email +import email.parser +import email.policy import pathlib import re import sys @@ -46,7 +48,8 @@ def main(argv): # Parse the message from stdin as binary, as we can't assume any particular # encoding. - msg = email.message_from_binary_file(sys.stdin.buffer) + parser = email.parser.BytesParser(policy=email.policy.default) + msg = parser.parse(sys.stdin.buffer) # mailman can mangle the From header to work around DMARC rejection rules. # It then formats From as "Name via mailing-list <mailing-list@domain>" and |