diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2014-04-03 01:09:02 +0200 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2014-04-03 01:09:02 +0200 |
commit | 5ab34927f6ce281a71b8f4787f49c5082509161c (patch) | |
tree | 470f0e47eef2252dc62cfed6db5dae038b1de154 | |
parent | f01edd687c32d457a7961e048f7068c96b20d8ea (diff) | |
download | pep8-5ab34927f6ce281a71b8f4787f49c5082509161c.tar.gz |
Fix E501 not detected in comments with Python 2.5
-rw-r--r-- | CHANGES.txt | 2 | ||||
-rwxr-xr-x | pep8.py | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index d710adf..df9ad1d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,8 @@ Changelog * Fix false positive E121/E126 with multi-line strings. (Issue #265) +* Fix E501 not detected in comments with Python 2.5. + 1.5.1 (2014-03-27) ------------------ @@ -1164,6 +1164,15 @@ def filename_match(filename, patterns, default=True): return any(fnmatch(filename, pattern) for pattern in patterns) +if COMMENT_WITH_NL: + def _is_eol_token(token): + return (token[0] in (tokenize.NEWLINE, tokenize.NL) or + (token[0] == tokenize.COMMENT and token[1] == token[4])) +else: + def _is_eol_token(token): + return token[0] in (tokenize.NEWLINE, tokenize.NL) + + ############################################################################## # Framework to run all checks ############################################################################## @@ -1380,7 +1389,7 @@ class Checker(object): def maybe_check_physical(self, token): """If appropriate (based on token), check current physical line(s).""" # Called after every token, but act only on end of line. - if token[0] in (tokenize.NEWLINE, tokenize.NL): + if _is_eol_token(token): # Obviously, a newline token ends a single physical line. self.check_physical(token[4]) elif token[0] == tokenize.STRING and '\n' in token[1]: |