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