summaryrefslogtreecommitdiff
path: root/coverage/phystokens.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-11-21 09:59:43 -0500
committerNed Batchelder <ned@nedbatchelder.com>2009-11-21 09:59:43 -0500
commit2c31e11ba195a336e1b037f42907cd2e1c53e096 (patch)
treefa87019ede4432baa4a6f5487ec34bffdcffdebe /coverage/phystokens.py
parent6f4a40d34152b7d99be35f4127e76c8beb4d6c06 (diff)
downloadpython-coveragepy-git-2c31e11ba195a336e1b037f42907cd2e1c53e096.tar.gz
Handle one more bizarro edge case in tokenizing source: I couldn't look at my own phystokens.py file properly!
Diffstat (limited to 'coverage/phystokens.py')
-rw-r--r--coverage/phystokens.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/coverage/phystokens.py b/coverage/phystokens.py
index 2862490f..131b362a 100644
--- a/coverage/phystokens.py
+++ b/coverage/phystokens.py
@@ -15,6 +15,7 @@ def phys_tokens(toks):
"""
last_line = None
last_lineno = -1
+ last_ttype = None
for ttype, ttext, (slineno, scol), (elineno, ecol), ltext in toks:
if last_lineno != elineno:
if last_line and last_line[-2:] == "\\\n":
@@ -34,7 +35,11 @@ def phys_tokens(toks):
# so we need to figure out if the backslash is already in the
# string token or not.
inject_backslash = True
- if ttype == token.STRING:
+ if last_ttype == tokenize.COMMENT:
+ # Comments like this \
+ # should never result in a new token.
+ inject_backslash = False
+ elif ttype == token.STRING:
if "\n" in ttext and ttext.split('\n', 1)[0][-1] == '\\':
# It's a multiline string and the first line ends with
# a backslash, so we don't need to inject another.
@@ -49,6 +54,7 @@ def phys_tokens(toks):
last_line
)
last_line = ltext
+ last_ttype = ttype
yield ttype, ttext, (slineno, scol), (elineno, ecol), ltext
last_lineno = elineno