gh-153205: Set `MemoryError` in stackref array conversion (GH-153206)
(cherry picked from commit
08759ff1015552d58c1f6ffa13ea08b0ae32e6c0)
Co-authored-by: An Long <aisk@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
--- /dev/null
+Fix a potential :exc:`SystemError` during vector calls when memory allocation fails.
+A :exc:`MemoryError` is now raised instead.
// +1 in case PY_VECTORCALL_ARGUMENTS_OFFSET is set.
result = PyMem_Malloc((nargs + 1) * sizeof(PyObject *));
if (result == NULL) {
+ PyErr_NoMemory();
return NULL;
}
result++;