[PATCH 1 of 2] py3: use email.generator.BytesGenerator in patch.split()

Denis Laxalde denis at laxalde.org
Thu Oct 10 13:40:13 UTC 2019


Pulkit Goyal a écrit :
> On Thu, Oct 10, 2019 at 12:02 PM Denis Laxalde <denis at laxalde.org> wrote:
> >
> > # HG changeset patch
> > # User Denis Laxalde <denis.laxalde at logilab.fr>
> > # Date 1570697337 -7200
> > #      Thu Oct 10 10:48:57 2019 +0200
> > # Node ID 707fc6aeadc33b02888e057e549c05d886fb67b0
> > # Parent  52781d57313d512efb7150603104bea3ca11d0eb
> > 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.
> >
> > diff --git a/mercurial/mail.py b/mercurial/mail.py
> > index b478f38..8ee25bf 100644
> > --- a/mercurial/mail.py
> > +++ b/mercurial/mail.py
> > @@ -420,6 +420,8 @@ def mimeencode(ui, s, charsets=None, dis
> >
> >  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 +438,8 @@ if pycompat.ispy3:
> >
> >  else:
> >
> > +    Generator = email.generator.Generator
> 
> fixed this to `email.Generator.Generator` in flight.

Is this problematic? I did it on purpose as "email.generator" exists on
py2.7 and "email.Generator" appears to be a proxy to the latter. Not a
big deal though. (Should have mentioned this in the commit message.)


More information about the Mercurial-devel mailing list