mirror of https://github.com/python/cpython
Whitespace normalization.
This commit is contained in:
parent
afb44f47d9
commit
0bbfd83250
|
@ -30,7 +30,7 @@ def overrideRootMenu(root, flist):
|
|||
Replace the Tk root menu by something that's more appropriate for
|
||||
IDLE.
|
||||
"""
|
||||
# The menu that is attached to the Tk root (".") is also used by AquaTk for
|
||||
# The menu that is attached to the Tk root (".") is also used by AquaTk for
|
||||
# all windows that don't specify a menu of their own. The default menubar
|
||||
# contains a number of menus, none of which are appropriate for IDLE. The
|
||||
# Most annoying of those is an 'About Tck/Tk...' menu in the application
|
||||
|
@ -82,7 +82,7 @@ def overrideRootMenu(root, flist):
|
|||
|
||||
for mname, entrylist in Bindings.menudefs:
|
||||
menu = menudict.get(mname)
|
||||
if not menu:
|
||||
if not menu:
|
||||
continue
|
||||
for entry in entrylist:
|
||||
if not entry:
|
||||
|
@ -90,14 +90,14 @@ def overrideRootMenu(root, flist):
|
|||
else:
|
||||
label, eventname = entry
|
||||
underline, label = prepstr(label)
|
||||
accelerator = get_accelerator(Bindings.default_keydefs,
|
||||
accelerator = get_accelerator(Bindings.default_keydefs,
|
||||
eventname)
|
||||
def command(text=root, eventname=eventname):
|
||||
text.event_generate(eventname)
|
||||
menu.add_command(label=label, underline=underline,
|
||||
command=command, accelerator=accelerator)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ def test():
|
|||
self.assertEqual(lst, ['KeyboardInterrupt\n'])
|
||||
|
||||
# String exceptions are deprecated, but legal. The quirky form with
|
||||
# separate "type" and "value" tends to break things, because
|
||||
# separate "type" and "value" tends to break things, because
|
||||
# not isinstance(value, type)
|
||||
# and a string cannot be the first argument to issubclass.
|
||||
#
|
||||
|
@ -139,7 +139,7 @@ def test():
|
|||
err = traceback.format_exception_only(str_type, str_value)
|
||||
self.assert_(len(err) == 1)
|
||||
self.assert_(err[0] == str_type + ': ' + str_value + '\n')
|
||||
|
||||
|
||||
|
||||
def test_main():
|
||||
run_unittest(TracebackCases)
|
||||
|
|
|
@ -172,7 +172,7 @@ def format_exception_only(etype, value):
|
|||
isinstance(etype, types.InstanceType) or
|
||||
type(etype) is str):
|
||||
return [_format_final_exc_line(etype, value)]
|
||||
|
||||
|
||||
stype = etype.__name__
|
||||
|
||||
if not issubclass(etype, SyntaxError):
|
||||
|
@ -196,18 +196,18 @@ def format_exception_only(etype, value):
|
|||
# only three spaces to account for offset1 == pos 0
|
||||
lines.append(' %s^\n' % ''.join(caretspace))
|
||||
value = msg
|
||||
|
||||
|
||||
lines.append(_format_final_exc_line(stype, value))
|
||||
return lines
|
||||
|
||||
def _format_final_exc_line(etype, value):
|
||||
"""Return a list of a single line -- normal case for format_exception_only"""
|
||||
if value is None or not str(value):
|
||||
if value is None or not str(value):
|
||||
line = "%s\n" % etype
|
||||
else:
|
||||
line = "%s: %s\n" % (etype, _some_str(value))
|
||||
return line
|
||||
|
||||
|
||||
def _some_str(value):
|
||||
try:
|
||||
return str(value)
|
||||
|
|
Loading…
Reference in New Issue