Oren Milman added the comment: 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)' ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28298> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com