bpo-30399: Get rid of trailing comma in the repr of BaseException. (#1650)

This commit is contained in:
Serhiy Storchaka 2017-11-15 17:53:28 +02:00 committed by GitHub
parent aca7f574b0
commit f8a4c03ede
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 12 deletions

View file

@ -117,7 +117,11 @@ static PyObject *
BaseException_repr(PyBaseExceptionObject *self)
{
const char *name = _PyType_Name(Py_TYPE(self));
return PyUnicode_FromFormat("%s%R", name, self->args);
if (PyTuple_GET_SIZE(self->args) == 1)
return PyUnicode_FromFormat("%s(%R)", name,
PyTuple_GET_ITEM(self->args, 0));
else
return PyUnicode_FromFormat("%s%R", name, self->args);
}
/* Pickling support */