Mercurial > hg
changeset 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 | a83c9c79b722 |
children | 3460eee570f7 |
files | mercurial/mail.py mercurial/patch.py |
diffstat | 2 files changed, 6 insertions(+), 2 deletions(-) [+] |
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)
--- a/mercurial/patch.py Thu Oct 10 10:03:01 2019 +0200 +++ b/mercurial/patch.py Thu Oct 10 10:48:57 2019 +0200 @@ -11,7 +11,6 @@ import collections import contextlib import copy -import email import errno import hashlib import os @@ -107,7 +106,7 @@ def mimesplit(stream, cur): def msgfp(m): fp = stringio() - g = email.Generator.Generator(fp, mangle_from_=False) + g = mail.Generator(fp, mangle_from_=False) g.flatten(m) fp.seek(0) return fp