226 error = "" |
226 error = "" |
227 lines = traceback.format_exception_only(SyntaxError, detail) |
227 lines = traceback.format_exception_only(SyntaxError, detail) |
228 if sys.version_info[0] == 2: |
228 if sys.version_info[0] == 2: |
229 lines = [x.decode(sys.getfilesystemencoding()) for x in lines] |
229 lines = [x.decode(sys.getfilesystemencoding()) for x in lines] |
230 match = re.match('\s*File "(.+)", line (\d+)', |
230 match = re.match('\s*File "(.+)", line (\d+)', |
231 lines[0].replace('<string>', '{0}'.format(filename))) |
231 lines[0].replace('<string>', filename)) |
232 if match is not None: |
232 if match is not None: |
233 fn, line = match.group(1, 2) |
233 fn, line = match.group(1, 2) |
234 if lines[1].startswith('SyntaxError:'): |
234 if lines[1].startswith('SyntaxError:'): |
235 error = re.match('SyntaxError: (.+)', lines[1]).group(1) |
235 error = re.match('SyntaxError: (.+)', lines[1]).group(1) |
236 else: |
236 else: |