DebugClients/Python3/DebugClientBase.py

changeset 4642
f18d5fb9a53b
parent 4631
5c1a96925da4
child 4830
f609a22f43bd
child 4833
803bf753032a
equal deleted inserted replaced
4640:0b502e1bc0b9 4642:f18d5fb9a53b
773 if cmd == DebugProtocol.RequestEval: 773 if cmd == DebugProtocol.RequestEval:
774 try: 774 try:
775 value = eval( 775 value = eval(
776 arg, 776 arg,
777 self.currentThread.getCurrentFrame().f_globals, 777 self.currentThread.getCurrentFrame().f_globals,
778 self.currentThread.getFrameLocals(0)) 778 self.currentThread.getFrameLocals(self.framenr))
779 self.currentThread.storeFrameLocals(self.framenr)
779 except Exception: 780 except Exception:
780 # Report the exception and the traceback 781 # Report the exception and the traceback
781 try: 782 try:
782 type, value, tb = sys.exc_info() 783 type, value, tb = sys.exc_info()
783 sys.last_type = type 784 sys.last_type = type
804 805
805 return 806 return
806 807
807 if cmd == DebugProtocol.RequestExec: 808 if cmd == DebugProtocol.RequestExec:
808 _globals = self.currentThread.getCurrentFrame().f_globals 809 _globals = self.currentThread.getCurrentFrame().f_globals
809 _locals = self.currentThread.getFrameLocals(0) 810 _locals = self.currentThread.getFrameLocals(self.framenr)
810 try: 811 try:
811 code = compile(arg + '\n', '<stdin>', 'single') 812 code = compile(arg + '\n', '<stdin>', 'single')
812 exec(code, _globals, _locals) 813 exec(code, _globals, _locals)
814 self.currentThread.storeFrameLocals(self.framenr)
813 except Exception: 815 except Exception:
814 # Report the exception and the traceback 816 # Report the exception and the traceback
815 try: 817 try:
816 type, value, tb = sys.exc_info() 818 type, value, tb = sys.exc_info()
817 sys.last_type = type 819 sys.last_type = type
994 _locals["sys"].stdout = self.writestream 996 _locals["sys"].stdout = self.writestream
995 exec(code, _globals, _locals) 997 exec(code, _globals, _locals)
996 _locals["sys"].stdout = __stdout 998 _locals["sys"].stdout = __stdout
997 else: 999 else:
998 exec(code, _globals, _locals) 1000 exec(code, _globals, _locals)
1001
1002 self.currentThread.storeFrameLocals(self.framenr)
999 except SystemExit as exc: 1003 except SystemExit as exc:
1000 self.progTerminated(exc.code) 1004 self.progTerminated(exc.code)
1001 except Exception: 1005 except Exception:
1002 # Report the exception and the traceback 1006 # Report the exception and the traceback
1003 try: 1007 try:
1357 dict = self.debugMod.__dict__ 1361 dict = self.debugMod.__dict__
1358 else: 1362 else:
1359 scope = -1 1363 scope = -1
1360 elif scope: 1364 elif scope:
1361 dict = f.f_globals 1365 dict = f.f_globals
1366 elif f.f_globals is f.f_locals:
1367 scope = -1
1362 else: 1368 else:
1363 dict = f.f_locals 1369 dict = f.f_locals
1364 1370
1365 if f.f_globals is f.f_locals:
1366 scope = -1
1367
1368 varlist = [scope] 1371 varlist = [scope]
1369 1372
1370 if scope != -1: 1373 if scope != -1:
1371 keylist = dict.keys() 1374 keylist = dict.keys()
1372 1375
1402 dict = self.debugMod.__dict__ 1405 dict = self.debugMod.__dict__
1403 else: 1406 else:
1404 scope = -1 1407 scope = -1
1405 elif scope: 1408 elif scope:
1406 dict = f.f_globals 1409 dict = f.f_globals
1410 elif f.f_globals is f.f_locals:
1411 scope = -1
1407 else: 1412 else:
1408 dict = f.f_locals 1413 dict = f.f_locals
1409
1410 if f.f_globals is f.f_locals:
1411 scope = -1
1412 1414
1413 varlist = [scope, var] 1415 varlist = [scope, var]
1414 1416
1415 if scope != -1: 1417 if scope != -1:
1416 # search the correct dictionary 1418 # search the correct dictionary

eric ide

mercurial