mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
gh-99553: fix bug where an ExceptionGroup subclass can wrap a BaseException (GH-99572)
This commit is contained in:
parent
a220c6d1ee
commit
c8c6113398
4 changed files with 37 additions and 5 deletions
|
@ -753,7 +753,19 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
}
|
||||
else {
|
||||
/* Do nothing - we don't interfere with subclasses */
|
||||
/* user-defined subclass */
|
||||
if (nested_base_exceptions) {
|
||||
int nonbase = PyObject_IsSubclass((PyObject*)cls, PyExc_Exception);
|
||||
if (nonbase == -1) {
|
||||
goto error;
|
||||
}
|
||||
else if (nonbase == 1) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"Cannot nest BaseExceptions in '%.200s'",
|
||||
cls->tp_name);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!cls) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue