summaryrefslogtreecommitdiffstats
path: root/Lib/trace.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2014-06-29 21:44:05 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2014-06-29 21:44:05 (GMT)
commitf026dae130bf6f9015c4b212f16852ba4a3f3dec (patch)
treef3cef557d7c98cf965688901d63bb2d3cd705b8d /Lib/trace.py
parent15c6ed52390cade3b070bf4b7097cb1d121d9dac (diff)
downloadcpython-f026dae130bf6f9015c4b212f16852ba4a3f3dec.zip
cpython-f026dae130bf6f9015c4b212f16852ba4a3f3dec.tar.gz
cpython-f026dae130bf6f9015c4b212f16852ba4a3f3dec.tar.bz2
Fixes #10541: regrtest -T is broken
* makes test_trace tests restore the tracefunc after they run * write_results() in trace module will not terminate if lnotab cannot be found.
Diffstat (limited to 'Lib/trace.py')
-rwxr-xr-xLib/trace.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/trace.py b/Lib/trace.py
index 09fe9ee..1c888ac 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -326,16 +326,17 @@ class CoverageResults:
lnotab = _find_executable_linenos(filename)
else:
lnotab = {}
+ if lnotab:
+ source = linecache.getlines(filename)
+ coverpath = os.path.join(dir, modulename + ".cover")
+ with open(filename, 'rb') as fp:
+ encoding, _ = tokenize.detect_encoding(fp.readline)
+ n_hits, n_lines = self.write_results_file(coverpath, source,
+ lnotab, count, encoding)
+ if summary and n_lines:
+ percent = int(100 * n_hits / n_lines)
+ sums[modulename] = n_lines, percent, modulename, filename
- source = linecache.getlines(filename)
- coverpath = os.path.join(dir, modulename + ".cover")
- with open(filename, 'rb') as fp:
- encoding, _ = tokenize.detect_encoding(fp.readline)
- n_hits, n_lines = self.write_results_file(coverpath, source,
- lnotab, count, encoding)
- if summary and n_lines:
- percent = int(100 * n_hits / n_lines)
- sums[modulename] = n_lines, percent, modulename, filename
if summary and sums:
print("lines cov% module (path)")