https://github.com/python/cpython/commit/8010bf09dfe45b759cf7334343cac2a46e239221
commit: 8010bf09dfe45b759cf7334343cac2a46e239221
branch: 3.13
author: stevens <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-07-15T12:40:54Z
summary:
[3.13] gh-151126: Fix missing memory errors in `_interpretersmodule.c`
(#153765)
gh-151126: Fix missing memory errors in `_interpretersmodule.c` (#151624)
(cherry picked from commit 05225aa06a4c5eceaa2eb29e99c2d44d2dbfe295)
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-16-00-10.gh-issue-151126.tBqn6I.rst
M Modules/_interpretersmodule.c
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-16-00-10.gh-issue-151126.tBqn6I.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-16-00-10.gh-issue-151126.tBqn6I.rst
new file mode 100644
index 00000000000000..d495df43ede932
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-16-00-10.gh-issue-151126.tBqn6I.rst
@@ -0,0 +1,3 @@
+Fix a crash when sharing :class:`memoryview` objects between interpreters
+fails due to running out of memory. It now raises a proper
+:exc:`MemoryError`.
diff --git a/Modules/_interpretersmodule.c b/Modules/_interpretersmodule.c
index 4ff73d32d2095b..f5b43f1e47f948 100644
--- a/Modules/_interpretersmodule.c
+++ b/Modules/_interpretersmodule.c
@@ -92,7 +92,7 @@ xibufferview_from_xid(PyTypeObject *cls,
_PyCrossInterpreterData *data)
assert(_PyCrossInterpreterData_INTERPID(data) >= 0);
XIBufferViewObject *self = PyObject_Malloc(sizeof(XIBufferViewObject));
if (self == NULL) {
- return NULL;
+ return PyErr_NoMemory();
}
PyObject_Init((PyObject *)self, cls);
self->view = (Py_buffer *)_PyCrossInterpreterData_DATA(data);
@@ -174,6 +174,7 @@ _memoryview_shared(PyThreadState *tstate, PyObject *obj,
{
Py_buffer *view = PyMem_RawMalloc(sizeof(Py_buffer));
if (view == NULL) {
+ PyErr_NoMemory();
return -1;
}
if (PyObject_GetBuffer(obj, view, PyBUF_FULL_RO) < 0) {
_______________________________________________
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]