##// END OF EJS Templates
Merge pull request #2399 from takluyver/indentationerr...
Bussonnier Matthias -
r8435:6ad41149 merge
parent child Browse files
Show More
@@ -1716,7 +1716,7 b' class InteractiveShell(SingletonConfigurable):'
1716 self.write_err('No traceback available to show.\n')
1716 self.write_err('No traceback available to show.\n')
1717 return
1717 return
1718
1718
1719 if etype is SyntaxError:
1719 if issubclass(etype, SyntaxError):
1720 # Though this won't be called by syntax errors in the input
1720 # Though this won't be called by syntax errors in the input
1721 # line, there may be SyntaxError cases with imported code.
1721 # line, there may be SyntaxError cases with imported code.
1722 self.showsyntaxerror(filename)
1722 self.showsyntaxerror(filename)
@@ -1769,7 +1769,7 b' class InteractiveShell(SingletonConfigurable):'
1769 """
1769 """
1770 etype, value, last_traceback = self._get_exc_info()
1770 etype, value, last_traceback = self._get_exc_info()
1771
1771
1772 if filename and etype is SyntaxError:
1772 if filename and issubclass(etype, SyntaxError):
1773 try:
1773 try:
1774 value.filename = filename
1774 value.filename = filename
1775 except:
1775 except:
@@ -73,3 +73,23 b' class NonAsciiTest(unittest.TestCase):'
73 with tt.AssertPrints("ZeroDivisionError"):
73 with tt.AssertPrints("ZeroDivisionError"):
74 with tt.AssertPrints(u'дбИЖ', suppress=False):
74 with tt.AssertPrints(u'дбИЖ', suppress=False):
75 ip.run_cell('fail()')
75 ip.run_cell('fail()')
76
77 indentationerror_file = """if True:
78 zoon()
79 """
80
81 class IndentationErrorTest(unittest.TestCase):
82 def test_indentationerror_shows_line(self):
83 # See issue gh-2398
84 with tt.AssertPrints("IndentationError"):
85 with tt.AssertPrints("zoon()", suppress=False):
86 ip.run_cell(indentationerror_file)
87
88 with TemporaryDirectory() as td:
89 fname = os.path.join(td, "foo.py")
90 with open(fname, "w") as f:
91 f.write(indentationerror_file)
92
93 with tt.AssertPrints("IndentationError"):
94 with tt.AssertPrints("zoon()", suppress=False):
95 ip.magic('run %s' % fname)
@@ -552,7 +552,7 b' class ListTB(TBTools):'
552 # Not sure if this can still happen in Python 2.6 and above
552 # Not sure if this can still happen in Python 2.6 and above
553 list.append( py3compat.cast_unicode(stype) + '\n')
553 list.append( py3compat.cast_unicode(stype) + '\n')
554 else:
554 else:
555 if etype is SyntaxError:
555 if issubclass(etype, SyntaxError):
556 have_filedata = True
556 have_filedata = True
557 #print 'filename is',filename # dbg
557 #print 'filename is',filename # dbg
558 if not value.filename: value.filename = "<string>"
558 if not value.filename: value.filename = "<string>"
General Comments 0
You need to be logged in to leave comments. Login now