diff --git a/Lib/trace.py b/Lib/trace.py --- a/Lib/trace.py +++ b/Lib/trace.py @@ -503,14 +503,12 @@ import __main__ dict = __main__.__dict__ if not self.donothing: - threading.settrace(self.globaltrace) - sys.settrace(self.globaltrace) + _settrace(self.globaltrace) try: exec cmd in dict, dict finally: if not self.donothing: - sys.settrace(None) - threading.settrace(None) + _unsettrace() def runctx(self, cmd, globals=None, locals=None): if globals is None: globals = {}