summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorjab <jab@users.noreply.github.com>2018-03-22 11:26:06 (GMT)
committerIvan Levkivskyi <levkivskyi@gmail.com>2018-03-22 11:26:06 (GMT)
commit40472dd42de4f7265d456458cd13ad6894d736db (patch)
tree2e6defa875a783260642cf6fa2546f0db387b6a3 /Modules
parentd93b5161af12291f3f98a260c90cc2975ea9e9cd (diff)
downloadcpython-40472dd42de4f7265d456458cd13ad6894d736db.zip
cpython-40472dd42de4f7265d456458cd13ad6894d736db.tar.gz
cpython-40472dd42de4f7265d456458cd13ad6894d736db.tar.bz2
bpo-33018: Improve issubclass() error checking and message. (GH-5944)
This improves error message for situations when a non-class is checked w.r.t. an abstract base class.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_abc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_abc.c b/Modules/_abc.c
index 8628839..7daa18e 100644
--- a/Modules/_abc.c
+++ b/Modules/_abc.c
@@ -569,6 +569,11 @@ _abc__abc_subclasscheck_impl(PyObject *module, PyObject *self,
PyObject *subclass)
/*[clinic end generated code: output=b56c9e4a530e3894 input=1d947243409d10b8]*/
{
+ if (!PyType_Check(subclass)) {
+ PyErr_SetString(PyExc_TypeError, "issubclass() arg 1 must be a class");
+ return NULL;
+ }
+
PyObject *ok, *mro = NULL, *subclasses = NULL, *result = NULL;
Py_ssize_t pos;
int incache;