Message 277704 - Python tracker (original) (raw)
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)'