[docs] [issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

Serhiy Storchaka report at bugs.python.org
Wed Dec 11 21:20:57 CET 2013


Serhiy Storchaka added the comment:

Even with last patch int() can return non-int:

>>> class A(int):
...     def __int__(self): return True
...     def __repr__(self): return '<A>'
... 
>>> class B:
...     def __int__(self): return A()
... 
>>> class C:
...     def __trunc__(self): return A()
... 
>>> int(B())
<A>
>>> int(C())
True

----------

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


More information about the docs mailing list