gh-103590: do not wrap a single exception raised from a try-except* (#103665)

This commit is contained in:
Irit Katriel
2023-04-27 12:52:15 +01:00
committed by GitHub
parent 78942ecd9b
commit 63842bd907
4 changed files with 32 additions and 25 deletions

View File

@@ -1421,7 +1421,12 @@ _PyExc_PrepReraiseStar(PyObject *orig, PyObject *excs)
if (res < 0) {
goto done;
}
result = _PyExc_CreateExceptionGroup("", raised_list);
if (PyList_GET_SIZE(raised_list) > 1) {
result = _PyExc_CreateExceptionGroup("", raised_list);
}
else {
result = Py_NewRef(PyList_GetItem(raised_list, 0));
}
if (result == NULL) {
goto done;
}