Skip to content

Commit bc8294c

Browse files
miss-islingtonchristianaurichzmStanFromIreland
authored
[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>
1 parent cfbbf8b commit bc8294c

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a crash in a debug build when creating an :exc:`ExceptionGroup` or
2+
:exc:`BaseExceptionGroup` fails with :exc:`MemoryError`. Patch by Christian
3+
Aurich Zanettini Martins.

‎Objects/exceptions.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -998,11 +998,11 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
998998
*/
999999
cls = (PyTypeObject*)PyExc_BaseExceptionGroup;
10001000
}
1001-
PyBaseExceptionGroupObject *self =
1002-
PyBaseExceptionGroupObject_CAST(BaseException_new(cls, args, kwds));
1003-
if (!self) {
1001+
PyObject *op = BaseException_new(cls, args, kwds);
1002+
if (!op) {
10041003
goto error;
10051004
}
1005+
PyBaseExceptionGroupObject *self = PyBaseExceptionGroupObject_CAST(op);
10061006

10071007
self->msg = Py_NewRef(message);
10081008
self->excs = exceptions;

0 commit comments

Comments
 (0)