Skip to content
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

gh-96046: Initialize ht_cached_keys in PyType_Ready() #96047

Merged
merged 10 commits into from
Aug 22, 2022
Prev Previous commit
Use MemoryError
  • Loading branch information
tiran committed Aug 19, 2022
commit 0db631aa8cb6a9f0a8c883b43cc873500bffd06b
6 changes: 2 additions & 4 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -6772,17 +6772,15 @@ type_ready_managed_dict(PyTypeObject *type)
if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) {
PyErr_Format(PyExc_SystemError,
"type %s has the Py_TPFLAGS_MANAGED_DICT flag "
"but not Py_TPFLAGS_HEAPTYPE flag.",
"but not Py_TPFLAGS_HEAPTYPE flag",
type->tp_name);
return -1;
}
PyHeapTypeObject* et = (PyHeapTypeObject*)type;
if (et->ht_cached_keys == NULL) {
et->ht_cached_keys = _PyDict_NewKeysForClass();
if (et->ht_cached_keys == NULL) {
PyErr_Format(PyExc_SystemError,
"failed to initialize ht_cached_keys of type %s.",
type->tp_name);
PyErr_NoMemory();
tiran marked this conversation as resolved.
Show resolved Hide resolved
return -1;
}
}
Expand Down