diff --git a/Modules/_testcapi/monitoring.c b/Modules/_testcapi/monitoring.c index 3f99836c1ebd83b..ab438d1d4b1cc8d 100644 --- a/Modules/_testcapi/monitoring.c +++ b/Modules/_testcapi/monitoring.c @@ -24,6 +24,7 @@ CodeLike_new(PyTypeObject *type, PyObject *args, PyObject *kwds) PyMonitoringState *states = (PyMonitoringState *)PyMem_Calloc( num_events, sizeof(PyMonitoringState)); if (states == NULL) { + PyErr_NoMemory(); return NULL; } PyCodeLikeObject *self = (PyCodeLikeObject *) type->tp_alloc(type, 0); diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c index ea3ad2b81c28668..9b45a9f117145b7 100644 --- a/Modules/_testinternalcapi.c +++ b/Modules/_testinternalcapi.c @@ -2033,6 +2033,7 @@ check_pyobject_uninitialized_is_freed(PyObject *self, { PyObject *op = (PyObject *)PyObject_Malloc(sizeof(PyObject)); if (op == NULL) { + PyErr_NoMemory(); return NULL; } /* Initialize reference count to avoid early crash in ceval or GC */ @@ -2049,6 +2050,7 @@ check_pyobject_forbidden_bytes_is_freed(PyObject *self, /* Allocate an incomplete PyObject structure: truncate 'ob_type' field */ PyObject *op = (PyObject *)PyObject_Malloc(offsetof(PyObject, ob_type)); if (op == NULL) { + PyErr_NoMemory(); return NULL; } /* Initialize reference count to avoid early crash in ceval or GC */