diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2012-12-22 10:51:44 +0100 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2012-12-22 10:51:44 +0100 |
commit | c308705eb319ae294c08c8ca51894c1d6ae5ac5f (patch) | |
tree | c2835969a09eaf4cb0e7338f4af48e1750783573 | |
parent | 29aa728bdd110c8742182f6a366625a661512706 (diff) | |
download | pep8-c308705eb319ae294c08c8ca51894c1d6ae5ac5f.tar.gz |
Fix regression when detecting W602 (due to e2bb226)
-rwxr-xr-x | pep8.py | 7 | ||||
-rw-r--r-- | testsuite/W60.py | 2 |
2 files changed, 6 insertions, 3 deletions
@@ -90,7 +90,8 @@ SKIP_TOKENS = frozenset([tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE, BENCHMARK_KEYS = ['directories', 'files', 'logical lines', 'physical lines'] INDENT_REGEX = re.compile(r'([ \t]*)') -RAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*,(.*)') +RAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*(,)') +RERAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*,\s*\w+\s*,\s*\w+') SELFTEST_REGEX = re.compile(r'(Okay|[EW]\d{3}):\s(.*)') ERRORCODE_REGEX = re.compile(r'[EW]\d{3}') DOCSTRING_REGEX = re.compile(r'u?r?["\']') @@ -974,8 +975,8 @@ def python_3000_raise_comma(logical_line): W602: raise DummyError, "Message" """ match = RAISE_COMMA_REGEX.match(logical_line) - if match and ',' not in match.group(1): - yield match.start(1) - 1, "W602 deprecated form of raising exception" + if match and not RERAISE_COMMA_REGEX.match(logical_line): + yield match.start(1), "W602 deprecated form of raising exception" def python_3000_not_equal(logical_line): diff --git a/testsuite/W60.py b/testsuite/W60.py index ee23d61..6d819ee 100644 --- a/testsuite/W60.py +++ b/testsuite/W60.py @@ -3,6 +3,8 @@ if a.has_key("b"): print a #: W602 raise DummyError, "Message" +#: W602 +raise ValueError, "hello %s %s" % (1, 2) #: Okay raise type_, val, tb #: W603 |