Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include the type name in the :exc:`TypeError` raised when ``items()`` returns a non-iterable during abstract method computation in :mod:`abc`. Patch by Jason Mak.
10 changes: 7 additions & 3 deletions Modules/_abc.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,14 @@ compute_abstract_methods(PyObject *self)
}
assert(PyList_Check(items));
for (Py_ssize_t pos = 0; pos < PyList_GET_SIZE(items); pos++) {
PyObject *it = PySequence_Fast(
PyList_GET_ITEM(items, pos),
"items() returned non-iterable");
PyObject *item_obj = PyList_GET_ITEM(items, pos);
PyObject *it = PySequence_Fast(item_obj, "items() returned non-iterable");
if (!it) {
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
PyErr_Format(PyExc_TypeError,
"items() returned non-iterable (type %T)",
item_obj);
}
goto error;
}
if (PySequence_Fast_GET_SIZE(it) != 2) {
Expand Down
Loading