summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2014-04-03 18:33:27 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2014-04-03 18:33:27 +0200
commit634f2132c4998aa198afbff5110d6da803617468 (patch)
treea77849867774daf71cac618c98ccd409fc861263
parent2715ed6391410f2bc51448619caf9ceb2b02731d (diff)
downloadpep8-634f2132c4998aa198afbff5110d6da803617468.tar.gz
Fix line number and offset for multi-line strings; issue #220
-rw-r--r--CHANGES.txt2
-rwxr-xr-xpep8.py16
2 files changed, 10 insertions, 8 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 49f97be..557894c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,8 @@ Changes:
Bug fixes:
+* Fix line number reported for multi-line strings. (Issue #220)
+
* Fix false positive E121/E126 with multi-line strings. (Issue #265)
* Fix E501 not detected in comments with Python 2.5.
diff --git a/pep8.py b/pep8.py
index 1942a10..3b80de9 100755
--- a/pep8.py
+++ b/pep8.py
@@ -1348,15 +1348,15 @@ class Checker(object):
for result in self.run_check(check, argument_names) or ():
(offset, text) = result
if isinstance(offset, tuple):
- (orig_number, orig_offset) = offset
+ (li_number, li_offset) = offset
else:
- orig_number = token0[2][0]
- orig_offset = token0[2][1] + offset
- for token_offset, token in self.mapping:
- if offset >= token_offset:
- orig_number = token[2][0]
- orig_offset = (token[2][1] + offset - token_offset)
- self.report_error(orig_number, orig_offset, text, check)
+ (token_offset, token) = (0, token0)
+ for (token_offset, token) in self.mapping:
+ if offset < token_offset:
+ break
+ li_number = token[2][0]
+ li_offset = (token[2][1] + offset - token_offset)
+ self.report_error(li_number, li_offset, text, check)
if self.logical_line:
self.previous_indent_level = self.indent_level
self.previous_logical = self.logical_line