New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C API] stable_abi.py script must not include PyType_HasFeature() static inline function in the stable ABI #87856
Comments
I just ran "make regen-limited-abi" and it added PyType_HasFeature(): commit baf10da
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: 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 ;-) |
Pablo: My previous commit added PyType_HasFeature to Doc/data/stable_abi.dat. But it prevented me to fix another bug, PR 25135. So I merged this change (PR 25136) to unblock the CI. Feel free to revert/adjust my change as soon as it doesn't add PyType_HasFeature back into Doc/data/stable_abi.dat :-) |
Oh, I forgot the mention "Tests / Check if generated files are up to date" job error message: LD_LIBRARY_PATH=/home/runner/work/cpython/cpython:/opt/hostedtoolcache/Python/3.9.2/x64/lib ./python ./Tools/scripts/stable_abi.py check ./Doc/data/stable_abi.dat This error means that there are some missing symbols among the ones exported Check if this was a mistake and if not, update the file containing the limited ./Doc/data/stable_abi.dat You can read more about the limited API and its contracts at: https://docs.python.org/3/c-api/stable.html And in PEP-384: |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: