Disable the inline by default for the function API which is included in the stable ABI

Related issue [3.13] `Py_INCREF(PyExc_TypeError)` in stable ABI causes `python3.13: ./Include/internal/pycore_object.h:284: _PyObject_Init: Assertion '_PyType_HasFeature(typeobj, Py_TPFLAGS_HEAPTYPE) || _Py_IsImmortal(typeobj)' failed.` · Issue #121528 · python/cpython · GitHub

I’m not sure this topic is a part of Improving collection of stable ABI macros and inline functions cc @nicholasjng @encukou

I think the inline function will break the convention that the stable ABI have the same behavior(correct me plz if I’m wrong)

For example, the Py_INCREF in this case:

  1. We don’t have any check before we actually add the reference count when the Python version <= 3.11
  2. We add extra check for the immortal object when the Python >=3.12

Because of the inline, the behavior for the binary which is generated from the different Python version will have different behavior and I’m if we should call it undefined behavior.

I’m not sure disable the inline by default for the function API which is included in the stable ABI is a good idea. Feel free to correct me if I’m wrong

1 Like

Sorry for this miss. I found more detail here Reference Counting — Python 3.12.4 documentation

I think we already disable the inline for the stable ABI

1 Like