diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-07-04-16-48.gh-issue-153205.5fE8QZ.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-07-04-16-48.gh-issue-153205.5fE8QZ.rst new file mode 100644 index 00000000000000..3cfcf80d275a8e --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-07-04-16-48.gh-issue-153205.5fE8QZ.rst @@ -0,0 +1,2 @@ +Fix a potential :exc:SystemError during vector calls when memory allocation fails. +A :exc:MemoryError is now raised instead. diff --git a/Python/ceval.c b/Python/ceval.c index f3f03b28112137..3f636c3416e120 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1056,6 +1056,7 @@ _PyObjectArray_FromStackRefArray(_PyStackRef *input, Py_ssize_t nargs, PyObject // +1 in case PY_VECTORCALL_ARGUMENTS_OFFSET is set. result = PyMem_Malloc((nargs + 1) * sizeof(PyObject *)); if (result == NULL) { + PyErr_NoMemory(); return NULL; } }