bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015) (GH-11020)
(cherry picked from commit 4c49da0cb7434c676d70b9ccf38aca82ac0d64a9)
diff --git a/Modules/_abc.c b/Modules/_abc.c
index 9de199f..36c1757 100644
--- a/Modules/_abc.c
+++ b/Modules/_abc.c
@@ -728,6 +728,10 @@
// Weakref callback may remove entry from set.
// So we take snapshot of registry first.
PyObject **copy = PyMem_Malloc(sizeof(PyObject*) * registry_size);
+ if (copy == NULL) {
+ PyErr_NoMemory();
+ return -1;
+ }
PyObject *key;
Py_ssize_t pos = 0;
Py_hash_t hash;