8000 bpo-1635741: Enable unicode_release_interned() without insure or valgrind. by shihai1991 · Pull Request #21087 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-1635741: Enable unicode_release_interned() without insure or valgrind. #21087

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

Closed
Prev Previous commit
Next Next commit
update vars' name
  • Loading branch information
shihai1991 committed Jun 25, 2020
commit ec1671b8c7f07e9a30d9884e5e66803e4bf8d42d
18 changes: 9 additions & 9 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -15661,7 +15661,7 @@ static void
unicode_release_interned(void)
{
Py_ssize_t pos = 0;
PyObject *key, *value;
PyObject *s, *ignored_value;

if (interned == NULL || !PyDict_Check(interned)) {
return;
Expand All @@ -15676,29 +15676,29 @@ unicode_release_interned(void)

Py_ssize_t immortal_size = 0, mortal_size = 0;
#endif
while (PyDict_Next(interned, &pos, &key, &value FA9A )) {
if (PyUnicode_READY(key) == -1) {
while (PyDict_Next(interned, &pos, &s, &ignored_value)) {
if (PyUnicode_READY(s) == -1) {
Py_UNREACHABLE();
}
switch (PyUnicode_CHECK_INTERNED(key)) {
switch (PyUnicode_CHECK_INTERNED(s)) {
case SSTATE_INTERNED_IMMORTAL:
Py_SET_REFCNT(key, Py_REFCNT(key) + 1);
Py_SET_REFCNT(s, Py_REFCNT(s) + 1);
#ifdef INTERNED_STATS
immortal_size += PyUnicode_GET_LENGTH(key);
immortal_size += PyUnicode_GET_LENGTH(s);
#endif
break;
case SSTATE_INTERNED_MORTAL:
Py_SET_REFCNT(key, Py_REFCNT(key) + 2);
Py_SET_REFCNT(s, Py_REFCNT(s) + 2);
#ifdef INTERNED_STATS
mortal_size += PyUnicode_GET_LENGTH(key);
mortal_size += PyUnicode_GET_LENGTH(s);
#endif
break;
case SSTATE_NOT_INTERNED:
/* fall through */
default:
Py_UNREACHABLE();
}
_PyUnicode_STATE(key).interned = SSTATE_NOT_INTERNED;
_PyUnicode_STATE(s).interned = SSTATE_NOT_INTERNED;
}
#ifdef INTERNED_STATS
fprintf(stderr,
Expand Down
2 changes: 1 addition & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1260,13 +1260,13 @@ finalize_interp_types(PyThreadState *tstate, int is_main_interp)
_PyContext_Fini(tstate);

_PyDict_Fini(tstate);
_PyList_Fini(tstate);
_PyTuple_Fini(tstate);

_PySlice_Fini(tstate);

_PyBytes_Fini(tstate);
_PyUnicode_Fini(tstate);
_PyList_Fini(tstate);
_PyFloat_Fini(tstate);
_PyLong_Fini(tstate);
}
Expand Down
0