summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorDaniel Andrade <dangro@users.noreply.github.com>2019-09-11 15:29:44 (GMT)
committerStéphane Wirtel <stephane@wirtel.be>2019-09-11 15:29:44 (GMT)
commit4a12a178f4a6b9a59d97fecc727f2b6b28dfc85f (patch)
treeb6ade2edb070705da46e18b2cbe299f3107f983d /Objects
parent19f6940cd7fb91246b88e1fbdbce97a02e7f3fa1 (diff)
downloadcpython-4a12a178f4a6b9a59d97fecc727f2b6b28dfc85f.zip
cpython-4a12a178f4a6b9a59d97fecc727f2b6b28dfc85f.tar.gz
cpython-4a12a178f4a6b9a59d97fecc727f2b6b28dfc85f.tar.bz2
bpo-34331: Fix incorrectly pluralized abstract class error message. (GH-8670)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 7575e55..dfdac9e 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3753,6 +3753,7 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *joined;
PyObject *comma;
_Py_static_string(comma_id, ", ");
+ Py_ssize_t method_count;
/* Compute ", ".join(sorted(type.__abstractmethods__))
into joined. */
@@ -3773,14 +3774,18 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
joined = PyUnicode_Join(comma, sorted_methods);
+ method_count = PyObject_Length(sorted_methods);
Py_DECREF(sorted_methods);
if (joined == NULL)
return NULL;
+ if (method_count == -1)
+ return NULL;
PyErr_Format(PyExc_TypeError,
"Can't instantiate abstract class %s "
- "with abstract methods %U",
+ "with abstract method%s %U",
type->tp_name,
+ method_count > 1 ? "s" : "",
joined);
Py_DECREF(joined);
return NULL;