https://github.com/python/cpython/commit/bc8294c2643d037a70bc3698f879c0fa094fa60f
commit: bc8294c2643d037a70bc3698f879c0fa094fa60f
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-10-25T14:27:28Z
summary:

[3.14] gh-159294: Fix crash when creating an `ExceptionGroup` fails with 
`MemoryError` (GH-159295) (#160505)

Co-authored-by: Christian Aurich Zanettini Martins 
<[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2026-10-13-06-23-56.gh-issue-159294.9LTsNA.rst
M Objects/exceptions.c

diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-13-06-23-56.gh-issue-159294.9LTsNA.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-13-06-23-56.gh-issue-159294.9LTsNA.rst
new file mode 100644
index 00000000000000..9504f1f753cbec
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-13-06-23-56.gh-issue-159294.9LTsNA.rst
@@ -0,0 +1,3 @@
+Fix a crash in a debug build when creating an :exc:`ExceptionGroup` or
+:exc:`BaseExceptionGroup` fails with :exc:`MemoryError`. Patch by Christian
+Aurich Zanettini Martins.
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 67ba540b552a58..b3473751684f0f 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -998,11 +998,11 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject 
*args, PyObject *kwds)
          */
         cls = (PyTypeObject*)PyExc_BaseExceptionGroup;
     }
-    PyBaseExceptionGroupObject *self =
-        PyBaseExceptionGroupObject_CAST(BaseException_new(cls, args, kwds));
-    if (!self) {
+    PyObject *op = BaseException_new(cls, args, kwds);
+    if (!op) {
         goto error;
     }
+    PyBaseExceptionGroupObject *self = PyBaseExceptionGroupObject_CAST(op);
 
     self->msg = Py_NewRef(message);
     self->excs = exceptions;

_______________________________________________
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