diff -r e01ae92db699 -r 31965986ecd1 eric6/DebugClients/Python/DebugClientBase.py --- a/eric6/DebugClients/Python/DebugClientBase.py Sat Mar 06 10:00:52 2021 +0100 +++ b/eric6/DebugClients/Python/DebugClientBase.py Sun Mar 28 15:00:11 2021 +0200 @@ -626,20 +626,27 @@ _locals = ( self.currentThread.getFrameLocals( self.framenr)) + # transfer all locals into a new globals + # to emulate Python scoping rules + _updatedGlobals = {} + _updatedGlobals.update(_globals) + _updatedGlobals.update(_locals) #- reset sys.stdout to our redirector #- (unconditionally) if "sys" in _globals: - __stdout = _globals["sys"].stdout - _globals["sys"].stdout = self.writestream - exec(code, _globals, _locals) # secok - _globals["sys"].stdout = __stdout + __stdout = _updatedGlobals["sys"].stdout + _updatedGlobals["sys"].stdout = ( + self.writestream + ) + exec(code, _updatedGlobals, _locals) # secok + _updatedGlobals["sys"].stdout = __stdout elif "sys" in _locals: __stdout = _locals["sys"].stdout _locals["sys"].stdout = self.writestream - exec(code, _globals, _locals) # secok + exec(code, _updatedGlobals, _locals) # secok _locals["sys"].stdout = __stdout else: - exec(code, _globals, _locals) # secok + exec(code, _updatedGlobals, _locals) # secok self.currentThread.storeFrameLocals(self.framenr) except SystemExit as exc: