[issue2603] Make range __eq__ work

Alexander Belopolsky report at bugs.python.org
Fri Apr 25 23:59:40 CEST 2008


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

On Fri, Apr 25, 2008 at 5:31 PM, Benjamin Peterson
<report at bugs.python.org> wrote:
>  Comments?

In the range_hash function, len, start, step locals should be declared
Py_ssize_t, not long. Also, you can use range_length() instead of
PyObject_Size() and you need to clear error if you get len == -1.

See issue2690. With your patch,

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t

but

True

You can avoid this problem by using range_length_obj instead of
PyObject_Size in range_richcompare.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2603>
__________________________________


More information about the Python-bugs-list mailing list