[issue26423] Integer overflow in wrap_lenfunc() on 64-bit build of Windows with len > 2**31-1

Eryk Sun report at bugs.python.org
Wed Feb 24 10:56:58 EST 2016


Eryk Sun added the comment:

> the sq_length slot in the weakproxy type is set to proxy_length.

Nice. Its tp_getattro gets in the way of using __len__ directly, but this can be side stepped by manually binding the descriptor:

    class Test(object):
        def __len__(self):
            return 2**31 + 5

    >>> t = Test()
    >>> p = weakref.proxy(t)
    >>> p.__len__()
    2147483653L
    >>> type(p).__len__.__get__(p)()
    -2147483643

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26423>
_______________________________________


More information about the Python-bugs-list mailing list