summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-11-15 15:53:28 (GMT)
committerGitHub <noreply@github.com>2017-11-15 15:53:28 (GMT)
commitf8a4c03ede6048022f60a58d5a21b278b78a8a16 (patch)
treed9f7f1d0e827315be914b2408359067a12bcbaa2 /Objects
parentaca7f574b06c72c85a5e3e4b16a8a5e384a7c4a8 (diff)
downloadcpython-f8a4c03ede6048022f60a58d5a21b278b78a8a16.zip
cpython-f8a4c03ede6048022f60a58d5a21b278b78a8a16.tar.gz
cpython-f8a4c03ede6048022f60a58d5a21b278b78a8a16.tar.bz2
bpo-30399: Get rid of trailing comma in the repr of BaseException. (#1650)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 637d766..4901eb1 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -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 */