PyBind11 IntAndIndex() returns the value for __int__() instead of __index__() from PyLong_AsLong.
xref https://github.com/pybind/pybind11/issues/3408
This python-level script prints 21
on pypy3.8 and cpython3.8, but PyBind11 has a failing test that calls PyLong_AsLong and expects to get the output of __index__
not __int__
.
class mylong:
def __index__(self):
return 42
def __int__(self):
return 21
print(int(mylong()))