Skip to content

Commit f2384a6

Browse files
committed
Make IPython line extraction more resilient to syntax errors (fix #44)
1 parent a392fab commit f2384a6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: backslash/contrib/utils.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ def distill_slash_traceback(err, line_radius=5):
2727
returned = err.traceback.to_list()
2828
for frame in returned:
2929
if _is_ipython_frame(frame):
30-
commands = ast.literal_eval(frame['locals']['In']['value'])
30+
commands = frame['locals'].get('In', {}).get('value', None)
31+
if not commands:
32+
continue
33+
try:
34+
commands = ast.literal_eval(commands)
35+
except SyntaxError:
36+
continue
3137
frame['code_lines_before'], frame['code_line'], frame['code_lines_after'] = _splice_lines(commands, len(commands) -1, line_radius)
3238
frame['lineno'] = len(commands) - 1
3339
else:

0 commit comments

Comments
 (0)