[PATCH 04 of 16 eac] [py3] Work around __next__ vs next in extid generator

Denis Laxalde denis.laxalde at logilab.fr
Tue Oct 1 14:51:38 CEST 2019


Frank Bessou a écrit :
> 
> 
> On 01/10/2019 12:36, Denis Laxalde wrote:
> > # HG changeset patch
> > # User Denis Laxalde <denis.laxalde at logilab.fr>
> > # Date 1569918994 -7200
> > #      Tue Oct 01 10:36:34 2019 +0200
> > # Node ID 9df1fd6261a8d22b4ebc76ed51f0957a5038fcc2
> > # Parent  42c46223a5cb7763976f3fc2d2e3d0c74297c416
> > # Available At http://hg.logilab.org/review/cubes/eac
> > #              hg pull http://hg.logilab.org/review/cubes/eac -r 9df1fd6261a8
> > [py3] Work around __next__ vs next in extid generator
> 
> 
> I think that you can use `six.next(gen)` here instead of `gen.next` and
> `gen.__next__`:)

Not sure, because we actually need to return the .next/.__next__ method,
not call it. Alternatively it could be return lambda : next(gen) but I'm
not sure it'd be clearer...

> 
> > 
> > diff --git a/test/test_dataimport.py b/test/test_dataimport.py
> > index 9077d74..1f5b37e 100644
> > --- a/test/test_dataimport.py
> > +++ b/test/test_dataimport.py
> > @@ -23,7 +23,7 @@ from os.path import join, dirname
> >   import sys
> >   import unittest
> > -from six import reraise
> > +from six import PY2, reraise
> >   from six.moves import map
> >   from cubicweb import NoResultError
> > @@ -53,6 +53,15 @@ def extentities2dict(entities):
> >       return edict
> > +def mk_extid_generator():
> > +    """Predicate extid_generator."""
> > +    gen = map(str, count())
> > +    if PY2:
> > +        return gen.next
> > +    else:
> > +        return gen.__next__
> > +
> > + >   class EACXMLParserTC(unittest.TestCase):
> >       if sys.version_info < (3, 2):



More information about the saem-devel mailing list