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

timeless timeless at gmail.com
Mon Jun 6 15:27:54 EDT 2016


can't we have a py26 path? if we're already casing pythons, i don't
see a reason not to special case 2.6 too.

On Mon, Jun 6, 2016 at 11:33 AM, Martijn Pieters <mj at zopatista.com> wrote:
> On 6 June 2016 at 06:09, Yuya Nishihara <yuya at tcha.org> wrote:
>> On Sun, 05 Jun 2016 10:32:11 -0500, Pulkit Goyal wrote:
>>> # HG changeset patch
>>> # User Pulkit Goyal <7895pulkit at gmail.com>
>>> # Date 1465140428 -19800
>>> #      Sun Jun 05 20:57:08 2016 +0530
>>> # Node ID ae89177a49c51f66962202598a44643c1dd1d18f
>>> # Parent  118a605e3ad9e1d30c4fd8bacc8310167ae1f222
>>> py3: handling .iteritems() vs .items()
>>
>>> +def viewitems(dict):
>>> +
>>> +    # using methodcaller avoids having to create another Python call frame.
>>> +    if safehasattr(dict, 'viewitems'):
>>> +        viewitems = methodcaller('viewitems')
>>
>> viewitems can't be used. It does not exist in Python 2.6.
>>
>> https://docs.python.org/2.7/library/stdtypes.html#dict.viewitems
>
> Good catch! So it's `methodcaller('iteritems')` or bust then. Anything
> that *must* have a list of the key-value pairs can always call
> `list()` on that.
>
> --
> Martijn Pieters
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list