Terry J. Reedy <[email protected]> added the comment:
Since isinstance(Object.__call__, types.MethodType) is False, the 'fob' in
'inspect.signature(fob)' is Object. (See the initial get_argspec code.)
Indeed, 'inspect.signature(Object)' results in the traceback following
inspect.signature(fob) and 'isinstance(Object, types.MethodType)' results in
the last line thereof. Not returning 'False' strikes me as maybe a bug in
'isinstance'. Have you opened a report for this?
Directly importing and executing idlelib code is not supported (its is
'private'), but entering 'Object(' to cause IDLE to make the same call is. And
the result is worse than the exception. The IDLE gui process hangs, waiting
for the response from the socket connection to the user code process that never
comes. This is clearly a bug, regardless of whether the user code is buggy.
The relevant section of get_argspec is
try:
argspec = str(inspect.signature(fob))
except ValueError as err:
msg = str(err)
if msg.startswith(_invalid_method):
return _invalid_method
Signature() is documented as returning either ValueError or TypeError, and with
the 'bug' in isinstance, others are possible. So any error should be caught.
(The default of falling through and checking for a docstring signature is
correct.)
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38689>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com