[Python-checkins] r75028 - in python/branches/py3k: Doc/library/functions.rst Lib/test/test_range.py Misc/NEWS Objects/rangeobject.c
Mark Dickinson
dickinsm at gmail.com
Wed Sep 23 15:00:07 CEST 2009
On Wed, Sep 23, 2009 at 1:28 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> mark.dickinson wrote:
>> +static int
>> +range_contains(rangeobject *r, PyObject *ob) {
>> + if (PyLong_Check(ob)) {
>> Could we be a little more generous here and use operator.index?
But that would be a behaviour change; is that desirable? E.g.,
Python 3.2a0 (py3k:74790, Sep 23 2009, 13:57:45)
[GCC 4.2.1 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class C:
... def __index__(self): return 3
... def __eq__(self, other): return True
...
>>> C() in range(0, 10, 2)
True
(Strictly speaking, I guess this patch is already a behaviour change for
subclasses of int that override __eq__ in weird ways).
Mark
More information about the Python-checkins
mailing list