[PATCH 2 of 7] py3: rewrite itervalues() as values() by importer

Gregory Szorc gregory.szorc at gmail.com
Mon Mar 13 16:00:09 EDT 2017


On Mon, Mar 13, 2017 at 12:58 PM, Gregory Szorc <gregory.szorc at gmail.com>
wrote:

> On Mon, Mar 13, 2017 at 11:55 AM, Yuya Nishihara <yuya at tcha.org> wrote:
>
>> # HG changeset patch
>> # User Yuya Nishihara <yuya at tcha.org>
>> # Date 1489419897 25200
>> #      Mon Mar 13 08:44:57 2017 -0700
>> # Node ID c9700b5cb641c10d8b0e6ac90896ebe5cb7c0658
>> # Parent  b7717d4dc60bcc3a3f4b7b85476954357f52783b
>> py3: rewrite itervalues() as values() by importer
>>
>> I'm not a great fan of these importer magics, but this should be okay
>> since
>> "itervalues" seems as unique name as "iteritems".
>>
>
> I agree it is similar and can be added without too much controversy. Since
> you'll be resending the series, how about adding iterkeys() while you are
> here?
>

Threading in my mail client may have confused me about the state of this
series. I guess you already sent a v2. So I'm fine dropping my iterkeys()
suggestion if it results in this being queued sooner.


>
>

>> diff --git a/mercurial/__init__.py b/mercurial/__init__.py
>> --- a/mercurial/__init__.py
>> +++ b/mercurial/__init__.py
>> @@ -310,10 +310,10 @@ if sys.version_info[0] >= 3:
>>                          if argidx is not None:
>>                              _ensureunicode(argidx)
>>
>> -                # It changes iteritems to items as iteritems is not
>> +                # It changes iteritems/values to items/values as they
>> are not
>>                  # present in Python 3 world.
>> -                elif fn == 'iteritems':
>> -                    yield t._replace(string='items')
>> +                elif fn in ('iteritems', 'itervalues'):
>> +                    yield t._replace(string=fn[4:])
>>                      continue
>>
>>              # Emit unmodified token.
>> @@ -323,7 +323,7 @@ if sys.version_info[0] >= 3:
>>      # ``replacetoken`` or any mechanism that changes semantics of module
>>      # loading is changed. Otherwise cached bytecode may get loaded
>> without
>>      # the new transformation mechanisms applied.
>> -    BYTECODEHEADER = b'HG\x00\x08'
>> +    BYTECODEHEADER = b'HG\x00\x09'
>>
>>      class hgloader(importlib.machinery.SourceFileLoader):
>>          """Custom module loader that transforms source code.
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170313/28ecf835/attachment.html>


More information about the Mercurial-devel mailing list