[Python-Dev] PyIndex_Check conflicts with PEP 384

Christian Tismer tismer at stackless.com
Fri Jun 1 09:10:30 EDT 2018

Hi friends,

when implementing the limited API for PySide2, I recognized
a little bug where a function was replaced by a macro.

The file number.rst on python 3.6 says

.. c:function:: int PyIndex_Check(PyObject *o)

   Returns ``1`` if *o* is an index integer (has the nb_index slot of the
   tp_as_number structure filled in), and ``0`` otherwise.

Without notice, this function was replaced by a macro a while
ago, which reads

#define PyIndex_Check(obj) \
   ((obj)->ob_type->tp_as_number != NULL && \
    (obj)->ob_type->tp_as_number->nb_index != NULL)

This contradicts PEP 384, because there is no way for non-heaptype
types to access the nb_index field.

If nobody objects, I would like to submit a patch that adds the
function back when the limited API is active.
I think to fix that before Python 3.7 is out.

Ciao -- Chris

Christian Tismer-Sperling    :^)   tismer at stackless.com
Software Consulting          :     http://www.stackless.com/
Karl-Liebknecht-Str. 121     :     http://pyside.org
14482 Potsdam                :     GPG key -> 0xFB7BEE0E
phone +49 173 24 18 776  fax +49 (30) 700143-0023

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 522 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180601/3cc19c04/attachment.sig>

More information about the Python-Dev mailing list