diff --git a/Lib/trace.py b/Lib/trace.py index 6e15e8b4bd8..38a13e2a9f0 100644 --- a/Lib/trace.py +++ b/Lib/trace.py @@ -502,15 +502,7 @@ def __init__(self, count=1, trace=1, countfuncs=0, countcallers=0, def run(self, cmd): import __main__ dict = __main__.__dict__ - if not self.donothing: - threading.settrace(self.globaltrace) - sys.settrace(self.globaltrace) - try: - exec cmd in dict, dict - finally: - if not self.donothing: - sys.settrace(None) - threading.settrace(None) + self.runctx(cmd, dict, dict) def runctx(self, cmd, globals=None, locals=None): if globals is None: globals = {}