gh-118331: Handle errors in _PyObject_SetManagedDict (#118334)

When detaching a dict, the `copy_values` call may fail due to
out-of-memory errors. This can be triggered by test_no_memory in
test_repl.
This commit is contained in:
Sam Gross 2024-04-29 15:49:01 -04:00 • committed by GitHub
parent ee3413c1c7
commit 79688b5b0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 13 deletions

View file

@ -3167,7 +3167,7 @@ subtype_setdict(PyObject *obj, PyObject *value, void *context)
}
if (Py_TYPE(obj)->tp_flags & Py_TPFLAGS_MANAGED_DICT) {
_PyObject_SetManagedDict(obj, value);
return _PyObject_SetManagedDict(obj, value);
}
else {
dictptr = _PyObject_ComputedDictPointer(obj);