eric6/DebugClients/Python/DebugClientBase.py

changeset 8159
08b8b3d2deb1
parent 8075
6774034a1e0f
child 8176
31965986ecd1
child 8207
d359172d11be
diff -r 16a34a0167ba -r 08b8b3d2deb1 eric6/DebugClients/Python/DebugClientBase.py
--- a/eric6/DebugClients/Python/DebugClientBase.py	Sat Mar 13 15:55:35 2021 +0100
+++ b/eric6/DebugClients/Python/DebugClientBase.py	Sat Mar 13 19:45:36 2021 +0100
@@ -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:

eric ide

mercurial