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

Co-authored-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
This commit is contained in:
authored and GitHub committed 2026-10-25 14:27:28 +00:00
1 parent cfbbf8be6b
commit bc8294c264
2 files changed
+6 -3

No files matched your search

@@ -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.
+3 -3
View File
@@ -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;