mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-46729: add number of sub-exceptions in str() of BaseExceptionGroup (GH-31294)
This commit is contained in:
parent
bba8008f99
commit
38b5acf867
4 changed files with 100 additions and 29 deletions
|
@ -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 *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue