https://github.com/python/cpython/commit/ef6437e6e28ba8a9aa3aef181ef16c35292ddc09
commit: ef6437e6e28ba8a9aa3aef181ef16c35292ddc09
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: cmaloney <[email protected]>
date: 2026-11-12T11:44:57-08:00
summary:

[3.15] gh-151126: set `MemoryError` on alloc failure in 
`_PyXIData_InitWithSize` (GH-156301) (#161905)

gh-151126: set `MemoryError` on alloc failure in `_PyXIData_InitWithSize` 
(GH-156301)
(cherry picked from commit a6018c587e4e8c154581b70d43149606ffce4783)

Co-authored-by: Thomas Kowalski <[email protected]>
Co-authored-by: Cody Maloney <[email protected]>

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2026-08-23-16-31-00.gh-issue-151126.phAWIG.rst
M Python/crossinterp.c

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..b1459de1c1596d
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-23-16-31-00.gh-issue-151126.phAWIG.rst
@@ -0,0 +1 @@
+Fix a crash when allocation failure occurs during :ref:`interp-object-sharing`.
diff --git a/Python/crossinterp.c b/Python/crossinterp.c
index b8dd5f11c2a44c..d189d7bcefe313 100644
--- a/Python/crossinterp.c
+++ b/Python/crossinterp.c
@@ -388,6 +388,8 @@ _PyXIData_InitWithSize(_PyXIData_t *xidata,
     _PyXIData_Init(xidata, interp, NULL, obj, new_object);
     xidata->data = PyMem_RawCalloc(1, size);
     if (xidata->data == NULL) {
+        Py_CLEAR(xidata->obj);
+        PyErr_NoMemory();
         return -1;
     }
     xidata->free = PyMem_RawFree;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to