]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46007: Exclude PyUnicode_CHECK_INTERNED() from limited C API (GH-29987)
authorVictor Stinner <vstinner@python.org>
Thu, 9 Dec 2021 08:58:09 +0000 (09:58 +0100)
committerGitHub <noreply@github.com>
Thu, 9 Dec 2021 08:58:09 +0000 (00:58 -0800)
Exclude the PyUnicode_CHECK_INTERNED() macro from the limited C API,
because it uses the PyASCIIObject structure which is excluded from
the limited C API.

Automerge-Triggered-By: GH:encukou
Doc/whatsnew/3.11.rst
Include/cpython/unicodeobject.h
Include/unicodeobject.h
Misc/NEWS.d/next/C API/2021-12-08-12-41-51.bpo-46007.sMgDLz.rst [new file with mode: 0644]

index 264a801da7899d8682bd200acaad11443b6825ea..4a113cdb8905c05f7baa3eee45683da71b9c07c7 100644 (file)
@@ -723,6 +723,12 @@ Porting to Python 3.11
   been included directly, consider including ``Python.h`` instead.
   (Contributed by Victor Stinner in :issue:`35134`.)
 
+* The :c:func:`PyUnicode_CHECK_INTERNED` macro has been excluded from the
+  limited C API. It was never usable there, because it used internal structures
+  which are not available in the limited C API.
+  (Contributed by Victor Stinner in :issue:`46007`.)
+
+
 Deprecated
 ----------
 
index e02137c7cad7d618833d5427048b995cbb416e6f..be5647c7d263c29838ba57e4a7df6b230c9facc4 100644 (file)
@@ -279,6 +279,10 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
 #define SSTATE_INTERNED_MORTAL 1
 #define SSTATE_INTERNED_IMMORTAL 2
 
+/* Use only if you know it's a string */
+#define PyUnicode_CHECK_INTERNED(op) \
+    (((PyASCIIObject *)(op))->state.interned)
+
 /* Return true if the string contains only ASCII characters, or 0 if not. The
    string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
    ready. */
index abce967caff78edf5bc1d2c80fcce6cbae537ea4..6426c5d06b445664697ab781bca4d2517e2227c3 100644 (file)
@@ -269,10 +269,6 @@ PyAPI_FUNC(PyObject *) PyUnicode_InternFromString(
 // and will be removed in Python 3.12. Use PyUnicode_InternInPlace() instead.
 Py_DEPRECATED(3.10) PyAPI_FUNC(void) PyUnicode_InternImmortal(PyObject **);
 
-/* Use only if you know it's a string */
-#define PyUnicode_CHECK_INTERNED(op) \
-    (((PyASCIIObject *)(op))->state.interned)
-
 /* --- wchar_t support for platforms which support it --------------------- */
 
 #ifdef HAVE_WCHAR_H
diff --git a/Misc/NEWS.d/next/C API/2021-12-08-12-41-51.bpo-46007.sMgDLz.rst b/Misc/NEWS.d/next/C API/2021-12-08-12-41-51.bpo-46007.sMgDLz.rst
new file mode 100644 (file)
index 0000000..6ed871b
--- /dev/null
@@ -0,0 +1,3 @@
+The :c:func:`PyUnicode_CHECK_INTERNED` macro has been excluded from the limited
+C API. It was never usable there, because it used internal structures which are
+not available in the limited C API. Patch by Victor Stinner.