X Tutup
Skip to content

Commit 13eb518

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

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

bpython/curtsiesfrontend/repl.py

Lines 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)
X Tutup