[issue12510] IDLE get_the_calltip mishandles raw strings

Roger Serwy report at bugs.python.org
Sun May 27 22:19:23 CEST 2012


Roger Serwy <roger.serwy at gmail.com> added the comment:

Terry, the original patch added "Not callable" because I wasn't sure what the consensus was on proper behavior. Now I know. :)

Attached is a revision against 3.3a3+ which omits the calltip if the object is not callable.

The behavior difference between 2.7 and 3.3 is due to a difference in "localcall" in rpc.py, where "CALLEXC" raises the exception in the IDLE front-end in 3.3 causing the crash, whereas in 2.7 the exception occurs in the subprocess. This is due to "rpc_marshal_exception.patch" for issue14200 not being backported to 2.7.

Entering []( or {}( or ''( will bring up a calltip. These calltips should not appear if the object is not callable. Take as an example:

    a = "string"
    a(

The previous code will bring up a calltip even though "a" is not callable. The HyperParser does its job by returning the string representing the object just before the paren. Checking whether this is a proper Python name won't fix this corner case. The "fetch_tip" method grabs the actual object given the string name using "get_entity" and then uses "get_argspec" to return constructor or callable arguments.

Checking if the object is callable must be done either in "get_entity" or in "get_argspec". I think it is cleaner to check in get_argspec, as is done in the attached patch.

----------
Added file: http://bugs.python.org/file25736/issue12510_rev1.patch

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


More information about the Python-bugs-list mailing list