mirror of https://github.com/python/cpython.git
Merge with 3.2 #12510
This commit is contained in:
commit
a317eef897
|
@ -67,18 +67,18 @@ def open_calltip(self, evalfuncs):
|
||||||
if not sur_paren:
|
if not sur_paren:
|
||||||
return
|
return
|
||||||
hp.set_index(sur_paren[0])
|
hp.set_index(sur_paren[0])
|
||||||
name = hp.get_expression()
|
expression = hp.get_expression()
|
||||||
if not name:
|
if not expression:
|
||||||
return
|
return
|
||||||
if not evalfuncs and (name.find('(') != -1):
|
if not evalfuncs and (expression.find('(') != -1):
|
||||||
return
|
return
|
||||||
argspec = self.fetch_tip(name)
|
argspec = self.fetch_tip(expression)
|
||||||
if not argspec:
|
if not argspec:
|
||||||
return
|
return
|
||||||
self.active_calltip = self._calltip_window()
|
self.active_calltip = self._calltip_window()
|
||||||
self.active_calltip.showtip(argspec, sur_paren[0], sur_paren[1])
|
self.active_calltip.showtip(argspec, sur_paren[0], sur_paren[1])
|
||||||
|
|
||||||
def fetch_tip(self, name):
|
def fetch_tip(self, expression):
|
||||||
"""Return the argument list and docstring of a function or class.
|
"""Return the argument list and docstring of a function or class.
|
||||||
|
|
||||||
If there is a Python subprocess, get the calltip there. Otherwise,
|
If there is a Python subprocess, get the calltip there. Otherwise,
|
||||||
|
@ -94,25 +94,27 @@ def fetch_tip(self, name):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
rpcclt = self.editwin.flist.pyshell.interp.rpcclt
|
rpcclt = self.editwin.flist.pyshell.interp.rpcclt
|
||||||
except:
|
except AttributeError:
|
||||||
rpcclt = None
|
rpcclt = None
|
||||||
if rpcclt:
|
if rpcclt:
|
||||||
return rpcclt.remotecall("exec", "get_the_calltip",
|
return rpcclt.remotecall("exec", "get_the_calltip",
|
||||||
(name,), {})
|
(expression,), {})
|
||||||
else:
|
else:
|
||||||
entity = self.get_entity(name)
|
entity = self.get_entity(expression)
|
||||||
return get_argspec(entity)
|
return get_argspec(entity)
|
||||||
|
|
||||||
def get_entity(self, name):
|
def get_entity(self, expression):
|
||||||
"Lookup name in a namespace spanning sys.modules and __main.dict__."
|
"""Return the object corresponding to expression evaluated
|
||||||
if name:
|
in a namespace spanning sys.modules and __main.dict__.
|
||||||
|
"""
|
||||||
|
if expression:
|
||||||
namespace = sys.modules.copy()
|
namespace = sys.modules.copy()
|
||||||
namespace.update(__main__.__dict__)
|
namespace.update(__main__.__dict__)
|
||||||
try:
|
try:
|
||||||
return eval(name, namespace)
|
return eval(expression, namespace)
|
||||||
# any exception is possible if evalfuncs True in open_calltip
|
except BaseException:
|
||||||
# at least Syntax, Name, Attribute, Index, and Key E. if not
|
# An uncaught exception closes idle, and eval can raise any
|
||||||
except:
|
# exception, especially if user classes are involved.
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _find_constructor(class_ob):
|
def _find_constructor(class_ob):
|
||||||
|
|
Loading…
Reference in New Issue