Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.)
2 changes: 1 addition & 1 deletion Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions Include/cpython/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the ``_PyUnicode_ClearStaticStrings()`` function from the C API.
6 changes: 3 additions & 3 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -16196,7 +16196,7 @@ _PyUnicode_Fini(PyThreadState *tstate)
Py_CLEAR(unicode_latin1[i]);
}
#endif
_PyUnicode_ClearStaticStrings();
unicode_clear_static_strings();
}

_PyUnicode_FiniEncodings(tstate);
Expand Down