Visitar URL original
gh-100227: Make the Global Interned Dict Safe for Isolated Interpreters by ericsnowcurrently · Pull Request #102925 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Always use the main interpreter when possibly resizing the interned d…
…ict.
  • Loading branch information
ericsnowcurrently committed Mar 22, 2023
commit a3ae02aeceb894cd9d2a814a79fb78ebefd65e58
16 changes: 14 additions & 2 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -14619,14 +14619,26 @@ store_interned(PyObject *obj)
PyObject *interned = get_interned_dict();
assert(interned != NULL);

// XXX Swap to the main interpreter.
/* Swap to the main interpreter, if necessary. */
PyThreadState *oldts = NULL;
if (!_Py_IsMainInterpreter(_PyInterpreterState_GET())) {
PyThreadState *main_tstate = get_interned_tstate();
if (main_tstate == NULL) {
return NULL;
}
oldts = PyThreadState_Swap(main_tstate);
assert(oldts != NULL);
}

PyObject *t = PyDict_SetDefault(interned, obj, obj);
if (t == NULL) {
PyErr_Clear();
}

// XXX Swap back.
/* Swap back. */
if (oldts != NULL) {
PyThreadState_Swap(oldts);
}

return t;
}
Expand Down