summaryrefslogtreecommitdiff
path: root/coverage/python.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-01-30 15:51:08 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-01-30 15:51:08 -0500
commit3511f6b7a95129ac216d3f547ea94293c80da92e (patch)
treee4fe0457662a3153ee4a8bdce3d507b8c145b2e4 /coverage/python.py
parent75cdf38508c2a9f5d0872905feaea14d206ac613 (diff)
parent903d797950b0d9c8a96bab36e246121c6143b675 (diff)
downloadpython-coveragepy-3511f6b7a95129ac216d3f547ea94293c80da92e.tar.gz
Merged who-tests-what-170
Diffstat (limited to 'coverage/python.py')
-rw-r--r--coverage/python.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/coverage/python.py b/coverage/python.py
index 4f58973..07d2347 100644
--- a/coverage/python.py
+++ b/coverage/python.py
@@ -50,6 +50,8 @@ def get_python_source(filename):
# Couldn't find source.
raise NoSource("No source for code: '%s'." % filename)
+ # Replace \f because of http://bugs.python.org/issue19035
+ source = source.replace(b'\f', b' ')
source = source.decode(source_encoding(source), "replace")
# Python code should always end with a line with a newline.
@@ -130,21 +132,16 @@ class PythonFileReporter(FileReporter):
filename=self.filename,
exclude=self.coverage._exclude_regex('exclude'),
)
+ self._parser.parse_source()
return self._parser
- @expensive
def lines(self):
"""Return the line numbers of statements in the file."""
- if self._statements is None:
- self._statements, self._excluded = self.parser.parse_source()
- return self._statements
+ return self.parser.statements
- @expensive
def excluded_lines(self):
"""Return the line numbers of statements in the file."""
- if self._excluded is None:
- self._statements, self._excluded = self.parser.parse_source()
- return self._excluded
+ return self.parser.excluded
def translate_lines(self, lines):
return self.parser.translate_lines(lines)