This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients BTaskaya, terry.reedy
Date 2020-04-04.21:58:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1586037502.75.0.762130276473.issue40180@roundup.psfhosted.org>
In-reply-to
Content
(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.
History
Date User Action Args
2020-04-04 21:58:22terry.reedysetrecipients: + terry.reedy, BTaskaya
2020-04-04 21:58:22terry.reedysetmessageid: <1586037502.75.0.762130276473.issue40180@roundup.psfhosted.org>
2020-04-04 21:58:22terry.reedylinkissue40180 messages
2020-04-04 21:58:22terry.reedycreate