diff mercurial/pycompat.py @ 38341:7b12a2d2eedc

py3: ditch email.parser.BytesParser which appears to be plain crap As I said before, BytesParser is a thin wrapper over the unicode Parser, and it's too thin to return bytes back. Today, I found it does normalize newline characters to '\n's thanks to the careless use of TextIOWrapper. So, this patch replaces BytesParser with Parser + TextIOWrapper, and fix newline handling. Since I don't know what's the least bad encoding strategy here, I just copied it from BytesParser. I've moved new parse() function from pycompat, as it is no longer a trivial wrapper.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 16 Jun 2018 19:31:07 +0900
parents 79dd61a4554f
children 152f4822d210
line wrap: on
line diff
--- a/mercurial/pycompat.py	Sat Jun 16 17:56:37 2018 +0900
+++ b/mercurial/pycompat.py	Sat Jun 16 19:31:07 2018 +0900
@@ -295,10 +295,6 @@
         ret = shlex.split(s.decode('latin-1'), comments, posix)
         return [a.encode('latin-1') for a in ret]
 
-    def emailparser(*args, **kwargs):
-        import email.parser
-        return email.parser.BytesParser(*args, **kwargs)
-
 else:
     import cStringIO
 
@@ -371,10 +367,6 @@
     rawinput = raw_input
     getargspec = inspect.getargspec
 
-    def emailparser(*args, **kwargs):
-        import email.parser
-        return email.parser.Parser(*args, **kwargs)
-
 isjython = sysplatform.startswith('java')
 
 isdarwin = sysplatform == 'darwin'