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").
This commit is contained in:
Victor Stinner 2020-05-14 01:11:54 +02:00 committed by GitHub
parent d72ea60521
commit d6fb53fe42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 6 deletions

View file

@ -964,3 +964,6 @@ Removed
* ``PyTuple_ClearFreeList()`` * ``PyTuple_ClearFreeList()``
* ``PyUnicode_ClearFreeList()``: the Unicode free list has been removed in * ``PyUnicode_ClearFreeList()``: the Unicode free list has been removed in
Python 3.3. Python 3.3.
* Remove ``_PyUnicode_ClearStaticStrings()`` function.
(Contributed by Victor Stinner in :issue:`39465`.)

View file

@ -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 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 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. Alternatively, _Py_static_string allows choosing the variable name.
_PyUnicode_FromId returns a borrowed reference to the interned string. _PyUnicode_FromId returns a borrowed reference to the interned string.

View file

@ -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.*/ /* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*); 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 /* 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) */ and where the hash values are equal (i.e. a very probable match) */

View file

@ -0,0 +1 @@
Remove the ``_PyUnicode_ClearStaticStrings()`` function from the C API.

View file

@ -2289,8 +2289,8 @@ _PyUnicode_FromId(_Py_Identifier *id)
return id->object; return id->object;
} }
void static void
_PyUnicode_ClearStaticStrings() unicode_clear_static_strings(void)
{ {
_Py_Identifier *tmp, *s = static_strings; _Py_Identifier *tmp, *s = static_strings;
while (s) { while (s) {
@ -16196,7 +16196,7 @@ _PyUnicode_Fini(PyThreadState *tstate)
Py_CLEAR(unicode_latin1[i]); Py_CLEAR(unicode_latin1[i]);
} }
#endif #endif
_PyUnicode_ClearStaticStrings(); unicode_clear_static_strings();
} }
_PyUnicode_FiniEncodings(tstate); _PyUnicode_FiniEncodings(tstate);