summaryrefslogtreecommitdiffstats
path: root/Objects/exceptions.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-04-27 11:52:15 (GMT)
committerGitHub <noreply@github.com>2023-04-27 11:52:15 (GMT)
commit63842bd90793c693f56bd8aad710b5267d41cf6d (patch)
treef0bdccdc533b62e48f7ad327981ca96eae387968 /Objects/exceptions.c
parent78942ecd9b1dbbd95e99cc298b0154fe126dac12 (diff)
downloadcpython-63842bd90793c693f56bd8aad710b5267d41cf6d.zip
cpython-63842bd90793c693f56bd8aad710b5267d41cf6d.tar.gz
cpython-63842bd90793c693f56bd8aad710b5267d41cf6d.tar.bz2
gh-103590: do not wrap a single exception raised from a try-except* (#103665)
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r--Objects/exceptions.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index a355244..55a6768 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -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;
}