From 14d3974db01b6c4b14a4829b4310b2511993aa8e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 15 Dec 2025 14:25:30 +0100 Subject: [PATCH] gh-142217: Recommend PyUnicode_InternFromString() to replace _PyUnicode_FromId() (GH-142746) --- Doc/deprecations/c-api-pending-removal-in-3.20.rst | 2 +- Doc/whatsnew/3.15.rst | 2 +- .../next/C_API/2025-12-03-14-41-07.gh-issue-141049.VuAUe2.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/deprecations/c-api-pending-removal-in-3.20.rst b/Doc/deprecations/c-api-pending-removal-in-3.20.rst index a813cb21dd4d..8de55bbe7e69 100644 --- a/Doc/deprecations/c-api-pending-removal-in-3.20.rst +++ b/Doc/deprecations/c-api-pending-removal-in-3.20.rst @@ -3,7 +3,7 @@ Pending removal in Python 3.20 * :c:func:`!_PyObject_CallMethodId`, :c:func:`!_PyObject_GetAttrId` and :c:func:`!_PyUnicode_FromId` are deprecated since 3.15 and will be removed in - 3.20. Instead, use :c:func:`PyUnicode_FromString()` and cache the result in + 3.20. Instead, use :c:func:`PyUnicode_InternFromString()` and cache the result in the module state, then call :c:func:`PyObject_CallMethod` or :c:func:`PyObject_GetAttr`. (Contributed by Victor Stinner in :gh:`141049`.) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index ccf6c76f1e0f..19762584ef79 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -1226,7 +1226,7 @@ Deprecated C APIs * :c:func:`!_PyObject_CallMethodId`, :c:func:`!_PyObject_GetAttrId` and :c:func:`!_PyUnicode_FromId` are deprecated since 3.15 and will be removed in - 3.20. Instead, use :c:func:`PyUnicode_FromString()` and cache the result in + 3.20. Instead, use :c:func:`PyUnicode_InternFromString()` and cache the result in the module state, then call :c:func:`PyObject_CallMethod` or :c:func:`PyObject_GetAttr`. (Contributed by Victor Stinner in :gh:`141049`.) diff --git a/Misc/NEWS.d/next/C_API/2025-12-03-14-41-07.gh-issue-141049.VuAUe2.rst b/Misc/NEWS.d/next/C_API/2025-12-03-14-41-07.gh-issue-141049.VuAUe2.rst index b0fcd24d4142..77cd5220d52f 100644 --- a/Misc/NEWS.d/next/C_API/2025-12-03-14-41-07.gh-issue-141049.VuAUe2.rst +++ b/Misc/NEWS.d/next/C_API/2025-12-03-14-41-07.gh-issue-141049.VuAUe2.rst @@ -1,5 +1,5 @@ :c:func:`!_PyObject_CallMethodId`, :c:func:`!_PyObject_GetAttrId` and :c:func:`!_PyUnicode_FromId` are deprecated since 3.15 and will be removed in -3.20. Instead, use :c:func:`PyUnicode_FromString()` and cache the result in +3.20. Instead, use :c:func:`PyUnicode_InternFromString()` and cache the result in the module state, then call :c:func:`PyObject_CallMethod` or :c:func:`PyObject_GetAttr`. Patch by Victor Stinner. -- 2.47.3