summaryrefslogtreecommitdiff
path: root/Lib/trace.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2003-06-26 14:56:17 +0000
committerJeremy Hylton <jeremy@alum.mit.edu>2003-06-26 14:56:17 +0000
commit546e34b654b03333cee0ba968c9f856a9b0b28d1 (patch)
tree9e189e68db7ff053dfcdeb632f830e1187d7db30 /Lib/trace.py
parent28b5bb33ea8640b6ee1e67b4af7b36b81a7d2659 (diff)
downloadcpython-git-546e34b654b03333cee0ba968c9f856a9b0b28d1.tar.gz
Enable tracing of multi-threaded applications.
Fix bug in computation of coverage percentage: Only count a line if it was executed or if we print the >>>>>> marker.
Diffstat (limited to 'Lib/trace.py')
-rw-r--r--Lib/trace.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/trace.py b/Lib/trace.py
index 9575911136..89f3162979 100644
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -50,6 +50,7 @@ import marshal
import os
import re
import sys
+import threading
import token
import tokenize
import types
@@ -317,9 +318,9 @@ class CoverageResults:
# #pragma: NO COVER
if lineno in lnotab and not PRAGMA_NOCOVER in lines[i]:
outfile.write(">>>>>> ")
+ n_lines += 1
else:
outfile.write(" ")
- n_lines += 1
outfile.write(lines[i].expandtabs(8))
outfile.close()
@@ -437,22 +438,26 @@ class Trace:
dict = __main__.__dict__
if not self.donothing:
sys.settrace(self.globaltrace)
+ threading.settrace(self.globaltrace)
try:
exec cmd in dict, dict
finally:
if not self.donothing:
sys.settrace(None)
+ threading.settrace(None)
def runctx(self, cmd, globals=None, locals=None):
if globals is None: globals = {}
if locals is None: locals = {}
if not self.donothing:
sys.settrace(self.globaltrace)
+ threading.settrace(self.globaltrace)
try:
exec cmd in globals, locals
finally:
if not self.donothing:
sys.settrace(None)
+ threading.settrace(None)
def runfunc(self, func, *args, **kw):
result = None