[Python-checkins] bpo-39465: Remove _PyUnicode_ClearStaticStrings() from C API (GH-20078)

Victor Stinner webhook-mailer at python.org
Wed May 13 19:11:59 EDT 2020


https://github.com/python/cpython/commit/d6fb53fe42d83a10f1372dd92ffaa6a01d2feffb
commit: d6fb53fe42d83a10f1372dd92ffaa6a01d2feffb
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-05-14T01:11:54+02:00
summary:

bpo-39465: Remove _PyUnicode_ClearStaticStrings() from C API (GH-20078)

Remove the _PyUnicode_ClearStaticStrings() function from the C API.
Make the function fully private (declare it with "static").

files:
A Misc/NEWS.d/next/C API/2020-05-14-00-36-19.bpo-39465.3a5g-X.rst
M Doc/whatsnew/3.9.rst
M Include/cpython/object.h
M Include/cpython/unicodeobject.h
M Objects/unicodeobject.c

diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index c57d702dce867..2fec790fe3a63 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -964,3 +964,6 @@ Removed
   * ``PyTuple_ClearFreeList()``
   * ``PyUnicode_ClearFreeList()``: the Unicode free list has been removed in
     Python 3.3.
+
+* Remove ``_PyUnicode_ClearStaticStrings()`` function.
+  (Contributed by Victor Stinner in :issue:`39465`.)
diff --git a/Include/cpython/object.h b/Include/cpython/object.h
index 8bf05a3271183..444f832f5bd8d 100644
--- a/Include/cpython/object.h
+++ b/Include/cpython/object.h
@@ -36,7 +36,7 @@ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
 
    PyId_foo is a static variable, either on block level or file level. On first
    usage, the string "foo" is interned, and the structures are linked. On interpreter
-   shutdown, all strings are released (through _PyUnicode_ClearStaticStrings).
+   shutdown, all strings are released.
 
    Alternatively, _Py_static_string allows choosing the variable name.
    _PyUnicode_FromId returns a borrowed reference to the interned string.
diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h
index 94326876292b6..4fd674ffea36e 100644
--- a/Include/cpython/unicodeobject.h
+++ b/Include/cpython/unicodeobject.h
@@ -1215,8 +1215,6 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
 
 /* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
 PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
-/* Clear all static strings. */
-PyAPI_FUNC(void) _PyUnicode_ClearStaticStrings(void);
 
 /* Fast equality check when the inputs are known to be exact unicode types
    and where the hash values are equal (i.e. a very probable match) */
diff --git a/Misc/NEWS.d/next/C API/2020-05-14-00-36-19.bpo-39465.3a5g-X.rst b/Misc/NEWS.d/next/C API/2020-05-14-00-36-19.bpo-39465.3a5g-X.rst
new file mode 100644
index 0000000000000..a08c3da566045
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-05-14-00-36-19.bpo-39465.3a5g-X.rst	
@@ -0,0 +1 @@
+Remove the ``_PyUnicode_ClearStaticStrings()`` function from the C API.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 826298c23a924..34b747ec7bb7e 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -2289,8 +2289,8 @@ _PyUnicode_FromId(_Py_Identifier *id)
     return id->object;
 }
 
-void
-_PyUnicode_ClearStaticStrings()
+static void
+unicode_clear_static_strings(void)
 {
     _Py_Identifier *tmp, *s = static_strings;
     while (s) {
@@ -16196,7 +16196,7 @@ _PyUnicode_Fini(PyThreadState *tstate)
             Py_CLEAR(unicode_latin1[i]);
         }
 #endif
-        _PyUnicode_ClearStaticStrings();
+        unicode_clear_static_strings();
     }
 
     _PyUnicode_FiniEncodings(tstate);



More information about the Python-checkins mailing list