Skip to content

Commit d6fb53f

Browse files
authored
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").
1 parent d72ea60 commit d6fb53f

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

Doc/whatsnew/3.9.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,3 +964,6 @@ Removed
964964
* ``PyTuple_ClearFreeList()``
965965
* ``PyUnicode_ClearFreeList()``: the Unicode free list has been removed in
966966
Python 3.3.
967+
968+
* Remove ``_PyUnicode_ClearStaticStrings()`` function.
969+
(Contributed by Victor Stinner in :issue:`39465`.)

Include/cpython/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
3636
3737
PyId_foo is a static variable, either on block level or file level. On first
3838
usage, the string "foo" is interned, and the structures are linked. On interpreter
39-
shutdown, all strings are released (through _PyUnicode_ClearStaticStrings).
39+
shutdown, all strings are released.
4040
4141
Alternatively, _Py_static_string allows choosing the variable name.
4242
_PyUnicode_FromId returns a borrowed reference to the interned string.

Include/cpython/unicodeobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,8 +1215,6 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
12151215

12161216
/* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
12171217
PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
1218-
/* Clear all static strings. */
1219-
PyAPI_FUNC(void) _PyUnicode_ClearStaticStrings(void);
12201218

12211219
/* Fast equality check when the inputs are known to be exact unicode types
12221220
and where the hash values are equal (i.e. a very probable match) */
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove the ``_PyUnicode_ClearStaticStrings()`` function from the C API.

Objects/unicodeobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,8 +2289,8 @@ _PyUnicode_FromId(_Py_Identifier *id)
22892289
return id->object;
22902290
}
22912291

2292-
void
2293-
_PyUnicode_ClearStaticStrings()
2292+
static void
2293+
unicode_clear_static_strings(void)
22942294
{
22952295
_Py_Identifier *tmp, *s = static_strings;
22962296
while (s) {
@@ -16196,7 +16196,7 @@ _PyUnicode_Fini(PyThreadState *tstate)
1619616196
Py_CLEAR(unicode_latin1[i]);
1619716197
}
1619816198
#endif
16199-
_PyUnicode_ClearStaticStrings();
16199+
unicode_clear_static_strings();
1620016200
}
1620116201

1620216202
_PyUnicode_FiniEncodings(tstate);

0 commit comments

Comments
 (0)