Skip to content

Commit 73325bb

Browse files
authored
bpo-46007: Exclude PyUnicode_CHECK_INTERNED() from limited C API (pythonGH-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
1 parent 5de39f4 commit 73325bb

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

Doc/whatsnew/3.11.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,12 @@ Porting to Python 3.11
723723
been included directly, consider including ``Python.h`` instead.
724724
(Contributed by Victor Stinner in :issue:`35134`.)
725725

726+
* The :c:func:`PyUnicode_CHECK_INTERNED` macro has been excluded from the
727+
limited C API. It was never usable there, because it used internal structures
728+
which are not available in the limited C API.
729+
(Contributed by Victor Stinner in :issue:`46007`.)
730+
731+
726732
Deprecated
727733
----------
728734

Include/cpython/unicodeobject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
279279
#define SSTATE_INTERNED_MORTAL 1
280280
#define SSTATE_INTERNED_IMMORTAL 2
281281

282+
/* Use only if you know it's a string */
283+
#define PyUnicode_CHECK_INTERNED(op) \
284+
(((PyASCIIObject *)(op))->state.interned)
285+
282286
/* Return true if the string contains only ASCII characters, or 0 if not. The
283287
string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
284288
ready. */

Include/unicodeobject.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,6 @@ PyAPI_FUNC(PyObject *) PyUnicode_InternFromString(
269269
// and will be removed in Python 3.12. Use PyUnicode_InternInPlace() instead.
270270
Py_DEPRECATED(3.10) PyAPI_FUNC(void) PyUnicode_InternImmortal(PyObject **);
271271

272-
/* Use only if you know it's a string */
273-
#define PyUnicode_CHECK_INTERNED(op) \
274-
(((PyASCIIObject *)(op))->state.interned)
275-
276272
/* --- wchar_t support for platforms which support it --------------------- */
277273

278274
#ifdef HAVE_WCHAR_H
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The :c:func:`PyUnicode_CHECK_INTERNED` macro has been excluded from the limited
2+
C API. It was never usable there, because it used internal structures which are
3+
not available in the limited C API. Patch by Victor Stinner.

0 commit comments

Comments
 (0)