summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 9b1c9f1..977dce5 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -836,7 +836,12 @@ BaseExceptionGroup_str(PyBaseExceptionGroupObject *self)
{
assert(self->msg);
assert(PyUnicode_Check(self->msg));
- return Py_NewRef(self->msg);
+
+ assert(PyTuple_CheckExact(self->excs));
+ Py_ssize_t num_excs = PyTuple_Size(self->excs);
+ return PyUnicode_FromFormat(
+ "%S (%zd sub-exception%s)",
+ self->msg, num_excs, num_excs > 1 ? "s" : "");
}
static PyObject *