diff --git a/IPython/core/ultratb.py b/IPython/core/ultratb.py index ebab505..632ae12 100644 --- a/IPython/core/ultratb.py +++ b/IPython/core/ultratb.py @@ -1202,7 +1202,8 @@ class SyntaxTB(ListTB): # 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)