◐ Shell
clean mode source ↗

Message 277704 - Python tracker

You are right about the terminology of course. My bad.

Anyway, the bug is not related to __index__ (or nb_index), because the three aforementioned functions are using (in case '!PyLong_Check(v)') PyArg_Parse with the formats 'l' or 'L'.
Ultimately, convertsimple (in Python/getargs.c) would call PyLong_AsLong or PyLong_AsLongLong (respectively).
These two (in case '!PyLong_Check(v)') only try to use nb_int, as documented:
    * https://docs.python.org/3.7/c-api/long.html?highlight=pylong_aslong#c.PyLong_AsLong
    * https://docs.python.org/3.7/c-api/long.html?highlight=pylong_aslong#c.PyLong_AsLongLong

But just in case, I ran the following:
    import array
    class LikeInt:
        def __init__(self, intVal):
            self.intVal = intVal
        def __index__(self):
            return self.intVal
    array.array('L').append(LikeInt(0))
and got a 'TypeError: an integer is required (got type LikeInt)'