[PATCH] py3: handling .iteritems() vs .items()

Jun Wu quark at fb.com
Tue Jun 7 11:23:26 EDT 2016


Excerpts from Martijn Pieters's message of 2016-06-07 14:26:59 +0100:
> On 7 June 2016 at 02:18, Gregory Szorc <gregory.szorc at gmail.com> wrote:
> > If it gets accepted, I would propose extending my custom module loader on
> > Python 3 to rewrite source code to accommodate API differences like
> > items/iteritems and range/xrange. See e.g.
> > https://hg.mozilla.org/users/gszorc_mozilla.com/hg/rev/7b72cfda136e 
> >
> > This would mean keeping the source Python 2 compatible and rewriting
> > "iteritems()" to "items()" on Python 3. This will require implementing
> > items() on our custom classes. I think that is a lesser evil than trying to
> > figure out when we should use one form or the other in our source.
> 
> I'd be uncomfortable with that; this is becoming a tad too much magic.
 
I think it's less magic if there is a tool to print out the transformed code.

IIUC the goal here to have py3 literal fixups as less as possible so things
like the annotation information will remain clean. From this perspective I
support rewrite iteriterms etc. in the module loader. Things like
CoffeeScript and LESS etc. are doing much crazier things and people use them.


More information about the Mercurial-devel mailing list