Skip to content

Commit

Permalink
Don't assume that SyntaxTB is always called with a SyntaxError
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Oct 9, 2013
1 parent ff8b9b0 commit a1f3801
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion IPython/core/ultratb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,8 @@ def structured_traceback(self, etype, value, elist, tb_offset=None,
# If the source file has been edited, the line in the syntax error can
# be wrong (retrieved from an outdated cache). This replaces it with
# the current value.
if isinstance(value.filename, py3compat.string_types) \
if isinstance(value, SyntaxError) \
and isinstance(value.filename, py3compat.string_types) \
and isinstance(value.lineno, int):
linecache.checkcache(value.filename)
newtext = ulinecache.getline(value.filename, value.lineno)
Expand Down

0 comments on commit a1f3801

Please sign in to comment.