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 13eb518

Browse filesBrowse files
committed
fix show_source method of curtsiesfrontend/repl to catch exceptions from get_source_of_current_name
1 parent ca74c46 commit 13eb518
Copy full SHA for 13eb518

1 file changed

+8-5Lines changed: 8 additions & 5 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/curtsiesfrontend/repl.py‎

Copy file name to clipboardExpand all lines: bpython/curtsiesfrontend/repl.py
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,13 +1300,16 @@ def pager(self, text):
13001300
self.focus_on_subprocess(command + [tmp.name])
13011301

13021302
def show_source(self):
1303-
source = self.get_source_of_current_name()
1304-
if source is None:
1305-
self.status_bar.message(_('Cannot show source.'))
1306-
else:
1303+
try:
1304+
source = self.get_source_of_current_name()
13071305
if self.config.highlight_show_source:
1308-
source = format(PythonLexer().get_tokens(source), TerminalFormatter())
1306+
source = format(PythonLexer().get_tokens(source),
1307+
TerminalFormatter())
13091308
self.pager(source)
1309+
except (ValueError, NameError), e:
1310+
self.status_bar.message(_(e))
1311+
except (AttributeError, IOError, TypeError), e:
1312+
self.status_bar.message(_('Failed to get source: %s' % e))
13101313

13111314
def help_text(self):
13121315
return (self.version_help_text() + '\n' + self.key_help_text()).encode('utf8')

0 commit comments

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