diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-09-21 07:21:05 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-09-21 07:21:05 -0400 |
commit | 341e737bd5010ffd794b029b3051a7ae210bfef2 (patch) | |
tree | 6a9cdd8c96f16e57ece089722e488e1944a27c51 /coverage/parser.py | |
parent | 0140c505eebe75035dbdb4723d233d15f439bc20 (diff) | |
download | python-coveragepy-git-341e737bd5010ffd794b029b3051a7ae210bfef2.tar.gz |
Exit arcs have to be corrected to first lines
We've long remapped line numbers to the first line of a multi-line
statement. But exit line numbers (negative numbers) were not remapped.
This meant we were needlessly chasing weirdnesses in implementations.
But the actual results of running coverage always remapped results to
the first line, so there's no point in tracking the unmapped line
numbers in our tests.
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index 12c2d0a5..f0d378c6 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -207,7 +207,11 @@ class PythonParser(object): def first_line(self, line): """Return the first line number of the statement including `line`.""" - return self._multiline.get(line, line) + if line < 0: + line = -self._multiline.get(-line, -line) + else: + line = self._multiline.get(line, line) + return line def first_lines(self, lines): """Map the line numbers in `lines` to the correct first line of the |