[issue40180] isinstance(cls_with_metaclass, non_type) raises KeyError
Batuhan Taskaya
report at bugs.python.org
Sat Apr 4 15:43:47 EDT 2020
Batuhan Taskaya <batuhanosmantaskaya at gmail.com> added the comment:
What would you expect in this case? Objects/abstract.c:2429 is where the isinstance code. If only returning False would be enough, something like this (untested) would be enough
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2436,6 +2436,10 @@ object_isinstance(PyObject *inst, PyObject *cls)
retval = PyObject_TypeCheck(inst, (PyTypeObject *)cls);
if (retval == 0) {
retval = _PyObject_LookupAttrId(inst, &PyId___class__, &icls);
+ if (retval == NULL && PyErr_Occurred()) {
+ PyErr_Clear();
+ retval = 0;
+ }
----------
nosy: +BTaskaya
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40180>
_______________________________________
More information about the Python-bugs-list
mailing list