This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients pablogsal, petr.viktorin, vstinner
Date 2021-04-01.09:37:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617269853.61.0.950135288092.issue43690@roundup.psfhosted.org>
In-reply-to
Content
I just ran "make regen-limited-abi" and it added PyType_HasFeature():

commit baf10da75072d1f8ec714d3c2c8550d34db343a9
Author: Victor Stinner <vstinner@python.org>
Date:   Thu Apr 1 11:29:46 2021 +0200

    bpo-43688: Run make regen-limited-abi (GH-25134)

diff --git a/Doc/data/stable_abi.dat b/Doc/data/stable_abi.dat
index 3adee103bc..ed20521b7f 100644
--- a/Doc/data/stable_abi.dat
+++ b/Doc/data/stable_abi.dat
@@ -192,6 +192,7 @@ PyExc_ConnectionRefusedError
 PyExc_ConnectionResetError
 PyExc_DeprecationWarning
 PyExc_EOFError
+PyExc_EncodingWarning
 PyExc_EnvironmentError
 PyExc_Exception
 PyExc_FileExistsError
@@ -615,6 +616,7 @@ PyType_GetFlags
 PyType_GetModule
 PyType_GetModuleState
 PyType_GetSlot
+PyType_HasFeature
 PyType_IsSubtype
 PyType_Modified
 PyType_Ready


The problem is that PyType_HasFeature() is currently implemented as a static inline function in the limited C API for best performance.

Issue about PyType_HasFeature() performance in CPython itself:
https://bugs.python.org/issue39542#msg372962

Currently, PyType_HasFeature() is declared in Include/object.h as:

static inline int
PyType_HasFeature(PyTypeObject *type, unsigned long feature)
{
    unsigned long flags;
#ifdef Py_LIMITED_API
    // PyTypeObject is opaque in the limited C API
    flags = PyType_GetFlags(type);
#else
    flags = type->tp_flags;
#endif
    return ((flags & feature) != 0);
}

IMO static inline functions must not be listed in the stable *ABI*. At the ABI level, libpython doesn't export "PyType_HasFeature" symbol:

$ objdump -T /lib64/libpython3.10.so.1.0|grep '\<PyObject_CallFunction\>'
00000000000fedf0 g    DF .text	00000000000000d0  Base        PyObject_CallFunction
$ objdump -T /lib64/libpython3.10.so.1.0|grep '\<PyType_HasFeature\>'
# nothing

"PyObject_CallFunction" symbol is exported, but not "PyType_HasFeature".

--

Maybe for the stable ABI, it would be a good idea to export PyType_HasFeature() as an opaque function. But that's out of the scope of this issue which is about the stable_abi.py script ;-)
History
Date User Action Args
2021-04-01 09:37:33vstinnersetrecipients: + vstinner, petr.viktorin, pablogsal
2021-04-01 09:37:33vstinnersetmessageid: <1617269853.61.0.950135288092.issue43690@roundup.psfhosted.org>
2021-04-01 09:37:33vstinnerlinkissue43690 messages
2021-04-01 09:37:33vstinnercreate