diff mercurial/mail.py @ 43326:ef81de93143e stable

py3: use a BytesParser in notify extension This is the first step to make the "long line" case in test-notify.t pass by fixing a UnicodeDecodeError on Python 3. We alias a parsebytes() in mail module, similarly as we already have a parse() function for Python 2 and Python 3 compatibility.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 24 Oct 2019 15:28:00 +0200
parents 7d4f2e4899c5
children 910827a2cb20
line wrap: on
line diff
--- a/mercurial/mail.py	Thu Oct 24 17:16:43 2019 +0200
+++ b/mercurial/mail.py	Thu Oct 24 15:28:00 2019 +0200
@@ -440,6 +440,9 @@
         finally:
             fp.detach()
 
+    def parsebytes(data):
+        ep = email.parser.BytesParser()
+        return ep.parsebytes(data)
 
 else:
 
@@ -449,6 +452,10 @@
         ep = email.parser.Parser()
         return ep.parse(fp)
 
+    def parsebytes(data):
+        ep = email.parser.Parser()
+        return ep.parsestr(data)
+
 
 def headdecode(s):
     '''Decodes RFC-2047 header'''