294 Public method to implement input() (Python 2) using the event loop. |
294 Public method to implement input() (Python 2) using the event loop. |
295 |
295 |
296 @param prompt the prompt to be shown (string) |
296 @param prompt the prompt to be shown (string) |
297 @return the entered string evaluated as a Python expresion |
297 @return the entered string evaluated as a Python expresion |
298 """ |
298 """ |
299 return eval(self.raw_input(prompt, True)) |
299 return eval(self.raw_input(prompt, True)) # secok |
300 |
300 |
301 def sessionClose(self, terminate=True): |
301 def sessionClose(self, terminate=True): |
302 """ |
302 """ |
303 Public method to close the session with the debugger and optionally |
303 Public method to close the session with the debugger and optionally |
304 terminate. |
304 terminate. |
305 |
305 |
306 @param terminate flag indicating to terminate (boolean) |
306 @param terminate flag indicating to terminate (boolean) |
307 """ |
307 """ |
308 try: |
308 try: |
309 self.set_quit() |
309 self.set_quit() |
310 except Exception: |
310 except Exception: # secok |
311 pass |
311 pass |
312 |
312 |
313 self.debugging = False |
313 self.debugging = False |
314 |
314 |
315 # make sure we close down our end of the socket |
315 # make sure we close down our end of the socket |
631 else: |
631 else: |
632 self.buffer = '' |
632 self.buffer = '' |
633 |
633 |
634 try: |
634 try: |
635 if self.running is None: |
635 if self.running is None: |
636 exec(code, self.debugMod.__dict__) |
636 exec(code, self.debugMod.__dict__) # secok |
637 else: |
637 else: |
638 if self.currentThread is None: |
638 if self.currentThread is None: |
639 # program has terminated |
639 # program has terminated |
640 self.running = None |
640 self.running = None |
641 _globals = self.debugMod.__dict__ |
641 _globals = self.debugMod.__dict__ |
659 ## reset sys.stdout to our redirector |
659 ## reset sys.stdout to our redirector |
660 ## (unconditionally) |
660 ## (unconditionally) |
661 if "sys" in _globals: |
661 if "sys" in _globals: |
662 __stdout = _globals["sys"].stdout |
662 __stdout = _globals["sys"].stdout |
663 _globals["sys"].stdout = self.writestream |
663 _globals["sys"].stdout = self.writestream |
664 exec(code, _globals, _locals) |
664 exec(code, _globals, _locals) # secok |
665 _globals["sys"].stdout = __stdout |
665 _globals["sys"].stdout = __stdout |
666 elif "sys" in _locals: |
666 elif "sys" in _locals: |
667 __stdout = _locals["sys"].stdout |
667 __stdout = _locals["sys"].stdout |
668 _locals["sys"].stdout = self.writestream |
668 _locals["sys"].stdout = self.writestream |
669 exec(code, _globals, _locals) |
669 exec(code, _globals, _locals) # secok |
670 _locals["sys"].stdout = __stdout |
670 _locals["sys"].stdout = __stdout |
671 else: |
671 else: |
672 exec(code, _globals, _locals) |
672 exec(code, _globals, _locals) # secok |
673 |
673 |
674 self.currentThread.storeFrameLocals(self.framenr) |
674 self.currentThread.storeFrameLocals(self.framenr) |
675 except SystemExit as exc: |
675 except SystemExit as exc: |
676 self.progTerminated(exc.code) |
676 self.progTerminated(exc.code) |
677 except Exception: |
677 except Exception: |