Author Oren Milman
Recipients Oren Milman, mark.dickinson, meador.inge, serhiy.storchaka
Date 2016-09-29.12:48:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1475153324.31.0.0116868910752.issue28298@psf.upfronthosting.co.za>
In-reply-to
Content
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)'
History
Date User Action Args
2016-09-29 12:48:44Oren Milmansetrecipients: + Oren Milman, mark.dickinson, meador.inge, serhiy.storchaka
2016-09-29 12:48:44Oren Milmansetmessageid: <1475153324.31.0.0116868910752.issue28298@psf.upfronthosting.co.za>
2016-09-29 12:48:44Oren Milmanlinkissue28298 messages
2016-09-29 12:48:44Oren Milmancreate