[issue16630] IDLE: Calltip fails if __getattr__ raises exception

Terry J. Reedy report at bugs.python.org
Fri Jan 10 03:08:08 CET 2014


Terry J. Reedy added the comment:

Get_entity already has try-except to block exceptions propagating from eval failure, so wrapping it is redundant. We only need worry about get_argspec.

I presume the failure is in get_argspec in the remote process:
    if hasattr(ob, '__call__'):
This can be replaced by callable(ob) as it converts exceptions to False. The appropriate return for non-callables is the current default, '', which results in no tip.

There are, however, other attribute accesses that could fail. I am reluctant to wrap get_argspec in its entirety, as that would mask bugs in Idle code as well as in user snippets. So I think each access should be protected. Since users will expect a tip for something that is a callable, I think a message might be appropriate. I checked that getattr(ob, name, default) does not convert exception to default.

Their are rpc calls in several places in Idle code. Unless failure can be triggered here in particular by user error, I do not think we should add specific protection here.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16630>
_______________________________________


More information about the Python-bugs-list mailing list