diff --git a/Misc/NEWS.d/next/Library/2026-06-22-09-41-31.gh-issue-151763.OOM0014.rst b/Misc/NEWS.d/next/Library/2026-06-22-09-41-31.gh-issue-151763.OOM0014.rst new file mode 100644 index 00000000000000..723aafb9f9202e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-22-09-41-31.gh-issue-151763.OOM0014.rst @@ -0,0 +1,3 @@ +Fix a crash in ``_interpchannels._channel_id()`` when memory allocation +fails while looking up module state. The function now correctly propagates +``MemoryError``. diff --git a/Modules/_interpchannelsmodule.c b/Modules/_interpchannelsmodule.c index 3614890757d69d..1d03c9d3197c4d 100644 --- a/Modules/_interpchannelsmodule.c +++ b/Modules/_interpchannelsmodule.c @@ -3484,6 +3484,9 @@ channelsmod__channel_id(PyObject *self, PyObject *args, PyObject *kwds) PyTypeObject *cls = state->ChannelIDType; PyObject *mod = get_module_from_owned_type(cls); + if (mod == NULL) { + return NULL; + } assert(mod == self); Py_DECREF(mod);