271 code = "" |
271 code = "" |
272 error = "" |
272 error = "" |
273 lines = traceback.format_exception_only(SyntaxError, detail) |
273 lines = traceback.format_exception_only(SyntaxError, detail) |
274 if sys.version_info[0] == 2: |
274 if sys.version_info[0] == 2: |
275 lines = [x.decode(sys.getfilesystemencoding()) for x in lines] |
275 lines = [x.decode(sys.getfilesystemencoding()) for x in lines] |
276 match = re.match('\s*File "(.+)", line (\d+)', |
276 match = re.match(r'\s*File "(.+)", line (\d+)', |
277 lines[0].replace('<string>', filename)) |
277 lines[0].replace('<string>', filename)) |
278 if match is not None: |
278 if match is not None: |
279 fn, line = match.group(1, 2) |
279 fn, line = match.group(1, 2) |
280 if lines[1].startswith('SyntaxError:'): |
280 if lines[1].startswith('SyntaxError:'): |
281 error = re.match('SyntaxError: (.+)', lines[1]).group(1) |
281 error = re.match('SyntaxError: (.+)', lines[1]).group(1) |