Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Lib/test/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ def tearDown(self):
def test_cover_files_written_no_highlight(self):
argv = '-m trace --count'.split() + [self.codefile]
status, stdout, stderr = assert_python_ok(*argv)
self.assertEqual(stderr, b'')
tracedir = os.path.dirname(os.path.abspath(trace.__file__))
tracecoverpath = os.path.join(tracedir, "trace.cover")
self.assertFalse(os.path.exists(tracecoverpath))

self.assertTrue(os.path.exists(self.coverfile))
with open(self.coverfile) as f:
self.assertEqual(f.read(),
Expand Down
14 changes: 4 additions & 10 deletions Lib/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@

import threading

def _settrace(func):
threading.settrace(func)
sys.settrace(func)

def _unsettrace():
sys.settrace(None)
threading.settrace(None)

PRAGMA_NOCOVER = "#pragma NO COVER"

class _Ignore:
Expand Down Expand Up @@ -451,12 +443,14 @@ def runctx(self, cmd, globals=None, locals=None):
if globals is None: globals = {}
if locals is None: locals = {}
if not self.donothing:
_settrace(self.globaltrace)
threading.settrace(self.globaltrace)
sys.settrace(self.globaltrace)
try:
exec(cmd, globals, locals)
finally:
if not self.donothing:
_unsettrace()
sys.settrace(None)
threading.settrace(None)

def runfunc(self, func, *args, **kw):
result = None
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Running the :mod:`trace` module no longer creates the ``trace.cover`` file.