Show More
@@ -1193,6 +1193,19 b' class SyntaxTB(ListTB):' | |||||
1193 | self.last_syntax_error = value |
|
1193 | self.last_syntax_error = value | |
1194 | ListTB.__call__(self,etype,value,elist) |
|
1194 | ListTB.__call__(self,etype,value,elist) | |
1195 |
|
1195 | |||
|
1196 | def structured_traceback(self, etype, value, elist, tb_offset=None, | |||
|
1197 | context=5): | |||
|
1198 | # If the source file has been edited, the line in the syntax error can | |||
|
1199 | # be wrong (retrieved from an outdated cache). This replaces it with | |||
|
1200 | # the current value. | |||
|
1201 | if isinstance(value.filename, str) and isinstance(value.lineno, int): | |||
|
1202 | linecache.checkcache(value.filename) | |||
|
1203 | newtext = ulinecache.getline(value.filename, value.lineno) | |||
|
1204 | if newtext: | |||
|
1205 | value.text = newtext | |||
|
1206 | return super(SyntaxTB, self).structured_traceback(etype, value, elist, | |||
|
1207 | tb_offset=tb_offset, context=context) | |||
|
1208 | ||||
1196 | def clear_err_state(self): |
|
1209 | def clear_err_state(self): | |
1197 | """Return the current error state and clear it""" |
|
1210 | """Return the current error state and clear it""" | |
1198 | e = self.last_syntax_error |
|
1211 | e = self.last_syntax_error |
General Comments 0
You need to be logged in to leave comments.
Login now