summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2012-12-22 10:51:44 +0100
committerFlorent Xicluna <florent.xicluna@gmail.com>2012-12-22 10:51:44 +0100
commitc308705eb319ae294c08c8ca51894c1d6ae5ac5f (patch)
treec2835969a09eaf4cb0e7338f4af48e1750783573
parent29aa728bdd110c8742182f6a366625a661512706 (diff)
downloadpep8-c308705eb319ae294c08c8ca51894c1d6ae5ac5f.tar.gz
Fix regression when detecting W602 (due to e2bb226)
-rwxr-xr-xpep8.py7
-rw-r--r--testsuite/W60.py2
2 files changed, 6 insertions, 3 deletions
diff --git a/pep8.py b/pep8.py
index 2c46c99..cef0103 100755
--- a/pep8.py
+++ b/pep8.py
@@ -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