diff mercurial/mail.py @ 43156:0e6a7ce81dde

py3: use email.generator.BytesGenerator in patch.split() This fixes test-import.t on python3. We add Generator alias in mail module to handle python2/python3 compatibility.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 10 Oct 2019 10:48:57 +0200
parents 8ff1ecfadcd1
children 3941e7063d03
line wrap: on
line diff
--- a/mercurial/mail.py	Thu Oct 10 10:03:01 2019 +0200
+++ b/mercurial/mail.py	Thu Oct 10 10:48:57 2019 +0200
@@ -9,6 +9,7 @@
 
 import email
 import email.charset
+import email.generator
 import email.header
 import email.message
 import email.parser
@@ -420,6 +421,8 @@
 
 if pycompat.ispy3:
 
+    Generator = email.generator.BytesGenerator
+
     def parse(fp):
         ep = email.parser.Parser()
         # disable the "universal newlines" mode, which isn't binary safe.
@@ -436,6 +439,8 @@
 
 else:
 
+    Generator = email.generator.Generator
+
     def parse(fp):
         ep = email.parser.Parser()
         return ep.parse(fp)