Override Interactive Interpreter method: Use Colorizing Color the offending position instead of printing it and pointing at it with a caret.
(self, filename=None, **kwargs)
| 707 | \n""".format(filename)) |
| 708 | |
| 709 | def showsyntaxerror(self, filename=None, **kwargs): |
| 710 | """Override Interactive Interpreter method: Use Colorizing |
| 711 | |
| 712 | Color the offending position instead of printing it and pointing at it |
| 713 | with a caret. |
| 714 | |
| 715 | """ |
| 716 | tkconsole = self.tkconsole |
| 717 | text = tkconsole.text |
| 718 | text.tag_remove("ERROR", "1.0", "end") |
| 719 | type, value, tb = sys.exc_info() |
| 720 | msg = getattr(value, 'msg', '') or value or "<no detail available>" |
| 721 | lineno = getattr(value, 'lineno', '') or 1 |
| 722 | offset = getattr(value, 'offset', '') or 0 |
| 723 | if offset == 0: |
| 724 | lineno += 1 #mark end of offending line |
| 725 | if lineno == 1: |
| 726 | pos = "iomark + %d chars" % (offset-1) |
| 727 | else: |
| 728 | pos = "iomark linestart + %d lines + %d chars" % \ |
| 729 | (lineno-1, offset-1) |
| 730 | tkconsole.colorize_syntax_error(text, pos) |
| 731 | tkconsole.resetoutput() |
| 732 | self.write("SyntaxError: %s\n" % msg) |
| 733 | tkconsole.showprompt() |
| 734 | |
| 735 | def showtraceback(self): |
| 736 | "Extend base class method to reset output properly" |
no test coverage detected