Show More
@@ -1682,20 +1682,12 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
1682 | sys.last_traceback = last_traceback |
|
1682 | sys.last_traceback = last_traceback | |
1683 |
|
1683 | |||
1684 | if filename and etype is SyntaxError: |
|
1684 | if filename and etype is SyntaxError: | |
1685 | # Work hard to stuff the correct filename in the exception |
|
|||
1686 | try: |
|
1685 | try: | |
1687 | msg, (dummy_filename, lineno, offset, line) = value |
|
1686 | value.filename = filename | |
1688 | except: |
|
1687 | except: | |
1689 | # Not the format we expect; leave it alone |
|
1688 | # Not the format we expect; leave it alone | |
1690 | pass |
|
1689 | pass | |
1691 |
|
|
1690 | ||
1692 | # Stuff in the right filename |
|
|||
1693 | try: |
|
|||
1694 | # Assume SyntaxError is a class exception |
|
|||
1695 | value = SyntaxError(msg, (filename, lineno, offset, line)) |
|
|||
1696 | except: |
|
|||
1697 | # If that failed, assume SyntaxError is a string |
|
|||
1698 | value = msg, (filename, lineno, offset, line) |
|
|||
1699 | stb = self.SyntaxTB.structured_traceback(etype, value, []) |
|
1691 | stb = self.SyntaxTB.structured_traceback(etype, value, []) | |
1700 | self._showtraceback(etype, value, stb) |
|
1692 | self._showtraceback(etype, value, stb) | |
1701 |
|
1693 |
@@ -548,44 +548,40 b' class ListTB(TBTools):' | |||||
548 | have_filedata = False |
|
548 | have_filedata = False | |
549 | Colors = self.Colors |
|
549 | Colors = self.Colors | |
550 | list = [] |
|
550 | list = [] | |
551 | try: |
|
551 | stype = Colors.excName + etype.__name__ + Colors.Normal | |
552 | stype = Colors.excName + etype.__name__ + Colors.Normal |
|
|||
553 | except AttributeError: |
|
|||
554 | stype = etype # String exceptions don't get special coloring |
|
|||
555 | if value is None: |
|
552 | if value is None: | |
|
553 | # Not sure if this can still happen in Python 2.6 and above | |||
556 | list.append( str(stype) + '\n') |
|
554 | list.append( str(stype) + '\n') | |
557 | else: |
|
555 | else: | |
558 | if etype is SyntaxError: |
|
556 | if etype is SyntaxError: | |
559 |
|
|
557 | have_filedata = True | |
560 | msg, (filename, lineno, offset, line) = value |
|
558 | #print 'filename is',filename # dbg | |
561 | except: |
|
559 | if not value.filename: value.filename = "<string>" | |
562 | have_filedata = False |
|
560 | list.append('%s File %s"%s"%s, line %s%d%s\n' % \ | |
563 | else: |
|
561 | (Colors.normalEm, | |
564 | have_filedata = True |
|
562 | Colors.filenameEm, value.filename, Colors.normalEm, | |
565 | #print 'filename is',filename # dbg |
|
563 | Colors.linenoEm, value.lineno, Colors.Normal )) | |
566 | if not filename: filename = "<string>" |
|
564 | if value.text is not None: | |
567 | list.append('%s File %s"%s"%s, line %s%d%s\n' % \ |
|
565 | i = 0 | |
568 | (Colors.normalEm, |
|
566 | while i < len(value.text) and value.text[i].isspace(): | |
569 | Colors.filenameEm, filename, Colors.normalEm, |
|
567 | i = i+1 | |
570 | Colors.linenoEm, lineno, Colors.Normal )) |
|
568 | list.append('%s %s%s\n' % (Colors.line, | |
571 | if line is not None: |
|
569 | value.text.strip(), | |
572 | i = 0 |
|
570 | Colors.Normal)) | |
573 | while i < len(line) and line[i].isspace(): |
|
571 | if value.offset is not None: | |
574 |
|
|
572 | s = ' ' | |
575 | list.append('%s %s%s\n' % (Colors.line, |
|
573 | for c in value.text[i:value.offset-1]: | |
576 |
|
|
574 | if c.isspace(): | |
577 |
|
|
575 | s = s + c | |
578 |
|
|
576 | else: | |
579 |
s = ' |
|
577 | s = s + ' ' | |
580 | for c in line[i:offset-1]: |
|
578 | list.append('%s%s^%s\n' % (Colors.caret, s, | |
581 |
|
|
579 | Colors.Normal) ) | |
582 | s = s + c |
|
580 | ||
583 | else: |
|
581 | try: | |
584 | s = s + ' ' |
|
582 | s = value.msg | |
585 | list.append('%s%s^%s\n' % (Colors.caret, s, |
|
583 | except Exception: | |
586 | Colors.Normal) ) |
|
584 | s = self._some_str(value) | |
587 | value = msg |
|
|||
588 | s = self._some_str(value) |
|
|||
589 | if s: |
|
585 | if s: | |
590 | list.append('%s%s:%s %s\n' % (str(stype), Colors.excName, |
|
586 | list.append('%s%s:%s %s\n' % (str(stype), Colors.excName, | |
591 | Colors.Normal, s)) |
|
587 | Colors.Normal, s)) | |
@@ -596,7 +592,7 b' class ListTB(TBTools):' | |||||
596 | if have_filedata: |
|
592 | if have_filedata: | |
597 | ipinst = ipapi.get() |
|
593 | ipinst = ipapi.get() | |
598 | if ipinst is not None: |
|
594 | if ipinst is not None: | |
599 | ipinst.hooks.synchronize_with_editor(filename, lineno, 0) |
|
595 | ipinst.hooks.synchronize_with_editor(value.filename, value.lineno, 0) | |
600 |
|
596 | |||
601 | return list |
|
597 | return list | |
602 |
|
598 |
@@ -13,7 +13,6 b' import unittest' | |||||
13 |
|
13 | |||
14 | # IPython imports |
|
14 | # IPython imports | |
15 | from IPython.lib import irunner |
|
15 | from IPython.lib import irunner | |
16 | from IPython.testing.decorators import known_failure_py3 |
|
|||
17 | from IPython.utils.py3compat import doctest_refactor_print |
|
16 | from IPython.utils.py3compat import doctest_refactor_print | |
18 |
|
17 | |||
19 | # Testing code begins |
|
18 | # Testing code begins | |
@@ -58,8 +57,6 b' class RunnerTestCase(unittest.TestCase):' | |||||
58 | self.assert_(mismatch==0,'Number of mismatched lines: %s' % |
|
57 | self.assert_(mismatch==0,'Number of mismatched lines: %s' % | |
59 | mismatch) |
|
58 | mismatch) | |
60 |
|
59 | |||
61 | # The SyntaxError appears differently in Python 3, for some reason. |
|
|||
62 | @known_failure_py3 |
|
|||
63 | def testIPython(self): |
|
60 | def testIPython(self): | |
64 | """Test the IPython runner.""" |
|
61 | """Test the IPython runner.""" | |
65 | source = doctest_refactor_print(""" |
|
62 | source = doctest_refactor_print(""" |
General Comments 0
You need to be logged in to leave comments.
Login now