cpython: 477508efe4ab (original) (raw)
Mercurial > cpython
changeset 77315:477508efe4ab 2.7
Issue 12510: Expand 2 bare excepts. Improve comments. Change deceptive name 'name' to 'expression' as the latter is what the string actually represents. The bug in this issue was only catching NameError and AttributeError when evaluating an expression that was not necessarily a name.
Terry Jan Reedy tjreedy@udel.edu | |
---|---|
date | Sun, 03 Jun 2012 00:58:36 -0400 |
parents | 5b267381eea0 |
children | d79c837b6bf3 |
files | Lib/idlelib/CallTips.py |
diffstat | 1 files changed, 16 insertions(+), 14 deletions(-)[+] [-] Lib/idlelib/CallTips.py 30 |
line wrap: on
line diff
--- a/Lib/idlelib/CallTips.py +++ b/Lib/idlelib/CallTips.py @@ -71,16 +71,16 @@ class CallTips: if not sur_paren: return hp.set_index(sur_paren[0])
name = hp.get_expression()[](#l1.7)
if not name or (not evalfuncs and name.find('(') != -1):[](#l1.8)
expression = hp.get_expression()[](#l1.9)
if not expression or (not evalfuncs and expression.find('(') != -1):[](#l1.10) return[](#l1.11)
arg_text = self.fetch_tip(name)[](#l1.12)
arg_text = self.fetch_tip(expression)[](#l1.13) if not arg_text:[](#l1.14) return[](#l1.15) self.calltip = self._make_calltip_window()[](#l1.16) self.calltip.showtip(arg_text, sur_paren[0], sur_paren[1])[](#l1.17)
If there is a Python subprocess, get the calltip there. Otherwise, @@ -96,25 +96,27 @@ class CallTips: """ try: rpcclt = self.editwin.flist.pyshell.interp.rpcclt
except:[](#l1.28)
except AttributeError:[](#l1.29) rpcclt = None[](#l1.30) if rpcclt:[](#l1.31) return rpcclt.remotecall("exec", "get_the_calltip",[](#l1.32)
(name,), {})[](#l1.33)
(expression,), {})[](#l1.34) else:[](#l1.35)
entity = self.get_entity(name)[](#l1.36)
entity = self.get_entity(expression)[](#l1.37) return get_arg_text(entity)[](#l1.38)
- def get_entity(self, name):
"Lookup name in a namespace spanning sys.modules and __main.dict__"[](#l1.41)
if name:[](#l1.42)
- def get_entity(self, expression):
"""Return the object corresponding to expression evaluated[](#l1.44)
in a namespace spanning sys.modules and __main.dict__.[](#l1.45)
"""[](#l1.46)
if expression:[](#l1.47) namespace = sys.modules.copy()[](#l1.48) namespace.update(__main__.__dict__)[](#l1.49) try:[](#l1.50)
return eval(name, namespace)[](#l1.51)
# any exception is possible if evalfuncs True in open_calltip[](#l1.52)
# at least Syntax, Name, Attribute, Index, and Key E. if not[](#l1.53)
except:[](#l1.54)
return eval(expression, namespace)[](#l1.55)
except BaseException:[](#l1.56)
# An uncaught exception closes idle, and eval can raise any[](#l1.57)
# exception, especially if user classes are involved.[](#l1.58) return None[](#l1.59)