[PATCH 4 of 4 RFC] pycompat: patch (del|get|has|set)attr to accept bytes on Python 3
Gregory Szorc
gregory.szorc at gmail.com
Mon Aug 15 12:17:00 EDT 2016
> On Aug 15, 2016, at 02:52, Yuya Nishihara <yuya at tcha.org> wrote:
>
>> On Sun, 14 Aug 2016 09:27:16 -0700, Gregory Szorc wrote:
>>> On Sun, Aug 14, 2016 at 2:33 AM, Yuya Nishihara <yuya at tcha.org> wrote:
>>> # HG changeset patch
>>> # User Yuya Nishihara <yuya at tcha.org>
>>> # Date 1471146681 -32400
>>> # Sun Aug 14 12:51:21 2016 +0900
>>> # Node ID 2a300f882c077fa014046db96b545f6aff771d32
>>> # Parent d53bd633898ec6edafccea9f798d314699faf90a
>>> pycompat: patch (del|get|has|set)attr to accept bytes on Python 3
>>>
>>> getattr() and setattr() are widely used in our code. We wouldn't probably
>>> want to rewrite every single call of getattr/setattr. delattr() and
>>> hasattr()
>>> aren't that important, but they are functions of the same kind.
>>>
>>> Another option would be util.(get|set)attr.
>>
>> I'm generally opposed to modifying the behavior of stdlib functionality
>> because, well, it's modifying the stdlib. Extensions may load
>> packages/modules that rely on the default behavior, perhaps in subtle ways.
>> I would prefer proxy functions (possibly in util.py) over modifying the
>> standard library.
>
> Maybe we can insert "from mercurial.pycompat import xrange, getattr, ..."
> by our Py3k importer, which should be better than hacking builtins and we
> can avoid bulk rewrites.
My initial reaction is I really like this idea!
More information about the Mercurial-devel
mailing list