]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-116936: Add PyType_GetModuleByDef() to the limited C API (#116937)
authorVictor Stinner <vstinner@python.org>
Mon, 25 Mar 2024 16:32:20 +0000 (17:32 +0100)
committerGitHub <noreply@github.com>
Mon, 25 Mar 2024 16:32:20 +0000 (16:32 +0000)
Doc/data/stable_abi.dat
Doc/whatsnew/3.13.rst
Include/cpython/object.h
Include/object.h
Lib/test/test_stable_abi_ctypes.py
Misc/NEWS.d/next/C API/2024-03-17-22-42-21.gh-issue-116936.tNrzfm.rst [new file with mode: 0644]
Misc/stable_abi.toml
PC/python3dll.c

index 565f134290802ac1b3129c2e9f9496a0743f65fd..2763bea5137cc7200bc23cf22453118462fe058c 100644 (file)
@@ -679,6 +679,7 @@ function,PyType_GenericNew,3.2,,
 function,PyType_GetFlags,3.2,,
 function,PyType_GetFullyQualifiedName,3.13,,
 function,PyType_GetModule,3.10,,
+function,PyType_GetModuleByDef,3.13,,
 function,PyType_GetModuleName,3.13,,
 function,PyType_GetModuleState,3.10,,
 function,PyType_GetName,3.11,,
index aba672dcb3f4563676490fd13a0e58e22c4ee304..e6234bf974ea47328a108aeecde9ace704594a23 100644 (file)
@@ -1742,6 +1742,9 @@ New Features
   :term:`strong reference` to the constant zero.
   (Contributed by Victor Stinner in :gh:`115754`.)
 
+* Add :c:func:`PyType_GetModuleByDef` to the limited C API
+  (Contributed by Victor Stinner in :gh:`116936`.)
+
 
 Porting to Python 3.13
 ----------------------
index 7512bb70c760fdd154515c8bceaf1d60787bda80..b64db1ba9a6dd20ef807ce26a43d2f30c4dda54b 100644 (file)
@@ -275,7 +275,6 @@ typedef struct _heaptypeobject {
 
 PyAPI_FUNC(const char *) _PyType_Name(PyTypeObject *);
 PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
-PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, PyModuleDef *);
 PyAPI_FUNC(PyObject *) PyType_GetDict(PyTypeObject *);
 
 PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
index 67a5e514c421c3c0c49c12d494fc1d2bd94eba0e..96790844a7b9f0eb740ad1199fa953d375866d22 100644 (file)
@@ -1247,6 +1247,10 @@ static inline int PyType_CheckExact(PyObject *op) {
 #  define PyType_CheckExact(op) PyType_CheckExact(_PyObject_CAST(op))
 #endif
 
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
+PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, PyModuleDef *);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 0e304853d399aa84606c9bed993f42be1e5a4922..d0e4f3c71c15e070fd8ed3c1ce9ec769d26f6c07 100644 (file)
@@ -708,6 +708,7 @@ SYMBOL_NAMES = (
     "PyType_GetFlags",
     "PyType_GetFullyQualifiedName",
     "PyType_GetModule",
+    "PyType_GetModuleByDef",
     "PyType_GetModuleName",
     "PyType_GetModuleState",
     "PyType_GetName",
diff --git a/Misc/NEWS.d/next/C API/2024-03-17-22-42-21.gh-issue-116936.tNrzfm.rst b/Misc/NEWS.d/next/C API/2024-03-17-22-42-21.gh-issue-116936.tNrzfm.rst
new file mode 100644 (file)
index 0000000..bd2abc9
--- /dev/null
@@ -0,0 +1,2 @@
+Add :c:func:`PyType_GetModuleByDef` to the limited C API. Patch by Victor
+Stinner.
index 6d6e484b0b6c672fdc10590103138487480ab4a6..14dda7db1c323e228e976761ccd03bba46c21ca4 100644 (file)
     added = '3.13'
 [function.Py_GetConstantBorrowed]
     added = '3.13'
+[function.PyType_GetModuleByDef]
+    added = '3.13'
index 147bfad44c374167be176880c5a56ce28a050ad1..c6fdc0bd73b9fe79cc6b7373efe0bd1a89515790 100755 (executable)
@@ -641,6 +641,7 @@ EXPORT_FUNC(PyType_GenericNew)
 EXPORT_FUNC(PyType_GetFlags)
 EXPORT_FUNC(PyType_GetFullyQualifiedName)
 EXPORT_FUNC(PyType_GetModule)
+EXPORT_FUNC(PyType_GetModuleByDef)
 EXPORT_FUNC(PyType_GetModuleName)
 EXPORT_FUNC(PyType_GetModuleState)
 EXPORT_FUNC(PyType_GetName)