mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-34171: Prevent creating Lib/trace.cover when run the trace module. (GH-8841)
This commit is contained in:
parent
8fdd331bbf
commit
c406d5cd74
3 changed files with 10 additions and 10 deletions
14
Lib/trace.py
14
Lib/trace.py
|
@ -63,14 +63,6 @@ from time import monotonic as _time
|
|||
|
||||
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:
|
||||
|
@ -451,12 +443,14 @@ class Trace:
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue