镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Merged
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
18 changes: 10 additions & 8 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -14533,6 +14533,15 @@ _PyUnicode_InitGlobalObjects(PyInterpreterState *interp)
return _PyStatus_OK();
}

// Initialize the global interned dict
PyObject *interned = PyDict_New();
if (interned == NULL) {
PyErr_Clear();
return _PyStatus_ERR("failed to create interned dict");
}

set_interned_dict(interned);

/* Intern statically allocated string identifiers and deepfreeze strings.
* This must be done before any module initialization so that statically
* allocated string identifiers are used instead of heap allocated strings.
Expand Down Expand Up @@ -14600,14 +14609,7 @@ PyUnicode_InternInPlace(PyObject **p)
}

PyObject *interned = get_interned_dict();
if (interned == NULL) {
interned = PyDict_New();
if (interned == NULL) {
PyErr_Clear(); /* Don't leave an exception */
return;
}
set_interned_dict(interned);
}
assert(interned != NULL);

PyObject *t = PyDict_SetDefault(interned, s, s);
if (t == NULL) {
Expand Down