From ca0dcfca2ad25541b9553d7110090f9ba49092d8 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 28 Nov 2022 08:24:10 +0200 Subject: 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 --- patch-save.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 " and -- cgit v1.2.3