From 8cf9517e69adbfe1491734c02a66b3e28c2842fc Mon Sep 17 00:00:00 2001 From: Thomas Kowalski Date: Sun, 23 Aug 2026 16:32:05 +0200 Subject: [PATCH] gh-151126: Set MemoryError on alloc failure in _PyXIData_InitWithSize --- .../2026-08-23-16-31-00.gh-issue-151126.phAWIG.rst | 2 ++ Python/crossinterp.c | 1 + 2 files changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-08-23-16-31-00.gh-issue-151126.phAWIG.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-08-23-16-31-00.gh-issue-151126.phAWIG.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-23-16-31-00.gh-issue-151126.phAWIG.rst new file mode 100644 index 00000000000000..f37e2585a9a3b2 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-23-16-31-00.gh-issue-151126.phAWIG.rst @@ -0,0 +1,2 @@ +Raise :exc:`MemoryError` on allocation failure in +``_PyXIData_InitWithSize``. diff --git a/Python/crossinterp.c b/Python/crossinterp.c index ed77c1be646e27..abd94e74f972b8 100644 --- a/Python/crossinterp.c +++ b/Python/crossinterp.c @@ -388,6 +388,7 @@ _PyXIData_InitWithSize(_PyXIData_t *xidata, _PyXIData_Init(xidata, interp, NULL, obj, new_object); xidata->data = PyMem_RawCalloc(1, size); if (xidata->data == NULL) { + PyErr_NoMemory(); return -1; } xidata->free = PyMem_RawFree;