Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 75e8e35

Browse filesBrowse files
lohmatajamlauter
authored andcommitted
Fix p_key to catch exceptions from get_source_of_current_name
1 parent f17eeec commit 75e8e35
Copy full SHA for 75e8e35

1 file changed

+6-4Lines changed: 6 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bpython/cli.py‎

Copy file name to clipboardExpand all lines: bpython/cli.py
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,14 +968,16 @@ def p_key(self, key):
968968
return ''
969969

970970
elif key in key_dispatch[config.show_source_key]:
971-
source = self.get_source_of_current_name()
972-
if source is not None:
971+
try:
972+
source = self.get_source_of_current_name()
973973
if config.highlight_show_source:
974974
source = format(PythonLexer().get_tokens(source),
975975
TerminalFormatter())
976976
page(source)
977-
else:
978-
self.statusbar.message(_('Cannot show source.'))
977+
except (ValueError, NameError), e:
978+
self.statusbar.message(_(e))
979+
except (AttributeError, IOError, TypeError), e:
980+
self.statusbar.message(_('Failed to get source: %s' % e))
979981
return ''
980982

981983
elif key in ('\n', '\r', 'PADENTER'):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.