Terry J. Reedy <tjre...@udel.edu> added the comment:
(Serhiy posted while I wrote this.) Sorry, I should have quoted the doc. " If object is not an object of the given type, the function always returns False." Raising instead is a bug -- even of the object itself is somewhat buggy. My knowledge of the C codebase is insufficient to review, let alone write, non-trivial changes. But I was curious where and why Object itself was being used as a key. I presume retval = _PyObject_LookupAttrId(inst, &PyId___class__, &icls); is roughly equivalent to Object.__class__ and indeed, that raises the KeyError. I presume the why has something to do with the interaction between metaclasses, properties, and slots. So if the details are correct, your patch should plug this hole. Can you submit a PR with added test? Issue background. The example is from Dan Snider, OP of #38689. When he typed 'Object(' into IDLE, IDLE tried to pop up a calltip. But inspect.signature(Object) failed with the (unexpected and undocumented) KeyError when it called isinstance(Object, types.MethodTypes), and IDLE froze. Given Python's flexibility, it can be hard to write code that works with any user code thrown at it. ---------- nosy: -serhiy.storchaka _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40180> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com