996 if text.endswith('\n') and not parens: |
996 if text.endswith('\n') and not parens: |
997 # The comment also ends a physical line. This works around |
997 # The comment also ends a physical line. This works around |
998 # Python < 2.6 behaviour, which does not generate NL after |
998 # Python < 2.6 behaviour, which does not generate NL after |
999 # a comment which is on a line by itself. |
999 # a comment which is on a line by itself. |
1000 self.tokens = [] |
1000 self.tokens = [] |
1001 except tokenize.TokenError, err: |
1001 except (SyntaxError, tokenize.TokenError) as err: |
1002 msg, (lnum, pos) = err.args |
1002 msg, (lnum, pos) = err.args |
1003 self.report_error_args(lnum, pos, "E901", "TokenError", msg) |
1003 self.report_error_args(lnum, pos, "E901", "TokenError", msg) |
1004 return self.file_errors |
1004 return self.file_errors |
1005 |
1005 |
1006 def report_error(self, line_number, offset, text, check): |
1006 def report_error(self, line_number, offset, text, check): |