MCPcopy Index your code
hub / github.com/python/cpython / showsyntaxerror

Method showsyntaxerror

Lib/code.py:97–116  ·  view source on GitHub ↗

Display the syntax error that just occurred. This doesn't display a stack trace because there isn't one. If a filename is given, it is stuffed in the exception instead of what was there before (because Python's parser always uses " " when reading from a strin

(self, filename=None, **kwargs)

Source from the content-addressed store, hash-verified

95 self.showtraceback()
96
97 def showsyntaxerror(self, filename=None, **kwargs):
98 """Display the syntax error that just occurred.
99
100 This doesn't display a stack trace because there isn't one.
101
102 If a filename is given, it is stuffed in the exception instead
103 of what was there before (because Python's parser always uses
104 "<string>" when reading from a string).
105
106 The output is written by self.write(), below.
107
108 """
109 try:
110 typ, value, tb = sys.exc_info()
111 if filename and issubclass(typ, SyntaxError):
112 value.filename = filename
113 source = kwargs.pop('source', "")
114 self._showtraceback(typ, value, None, source)
115 finally:
116 typ = value = tb = None
117
118 def showtraceback(self):
119 """Display the exception that just occurred.

Callers 1

runsourceMethod · 0.95

Calls 2

_showtracebackMethod · 0.95
popMethod · 0.45

Tested by

no test coverage detected