[pypy-issue] [issue1235] "__len__ should return bool or integer" inconsistant with CPython
Aaron Meurer
tracker at bugs.pypy.org
Wed Aug 15 03:49:50 CEST 2012
New submission from Aaron Meurer <asmeurer at gmail.com>:
CPython:
>>> class One(object):
... def __int__(self):
... return 1
...
>>> class Test(object):
... def __len__(self):
... return One()
...
>>> bool(Test())
True
PyPy (1.9):
>>>> class One(object):
.... def __int__(self):
.... return 1
....
>>>> class Test(object):
.... def __len__(self):
.... return One()
....
>>>> bool(Test())
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: __len__ should return bool or integer
I'm not sure if __int__ is the necessary thing that the object needs to have
defined, but clearly PyPy should allow __len__ to return custom objects assuming
that they have certain methods defined.
----------
messages: 4652
nosy: asmeurer, pypy-issue
priority: bug
status: unread
title: "__len__ should return bool or integer" inconsistant with CPython
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1235>
________________________________________
More information about the pypy-issue
mailing list