[Python-checkins] bpo-46007: Exclude PyUnicode_CHECK_INTERNED() from limited C API (GH-29987)
miss-islington
webhook-mailer at python.org
Thu Dec 9 03:58:22 EST 2021
https://github.com/python/cpython/commit/73325bbe774b16891f999fb557177206470676b1
commit: 73325bbe774b16891f999fb557177206470676b1
branch: main
author: Victor Stinner <vstinner at python.org>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-12-09T00:58:09-08:00
summary:
bpo-46007: Exclude PyUnicode_CHECK_INTERNED() from limited C API (GH-29987)
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
files:
A Misc/NEWS.d/next/C API/2021-12-08-12-41-51.bpo-46007.sMgDLz.rst
M Doc/whatsnew/3.11.rst
M Include/cpython/unicodeobject.h
M Include/unicodeobject.h
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 264a801da7899..4a113cdb8905c 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -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
----------
diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h
index e02137c7cad7d..be5647c7d263c 100644
--- a/Include/cpython/unicodeobject.h
+++ b/Include/cpython/unicodeobject.h
@@ -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. */
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index abce967caff78..6426c5d06b445 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -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
index 0000000000000..6ed871b9950af
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2021-12-08-12-41-51.bpo-46007.sMgDLz.rst
@@ -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.
More information about the Python-checkins
mailing list