DebugClients/Python3/DebugBase.py

branch
jsonrpc
changeset 5131
889ed5ff7a68
parent 5128
b6cbdba69967
child 5140
01484c0afbc6
equal deleted inserted replaced
5130:27fe451262bf 5131:889ed5ff7a68
197 """ 197 """
198 if self._dbgClient.callTraceEnabled: 198 if self._dbgClient.callTraceEnabled:
199 if not self.__skip_it(fromFrame) and not self.__skip_it(toFrame): 199 if not self.__skip_it(fromFrame) and not self.__skip_it(toFrame):
200 if event in ["call", "return"]: 200 if event in ["call", "return"]:
201 fr = fromFrame 201 fr = fromFrame
202 # TODO: change from and to info to a dictionary
202 fromStr = "{0}:{1}:{2}".format( 203 fromStr = "{0}:{1}:{2}".format(
203 self._dbgClient.absPath(self.fix_frame_filename(fr)), 204 self._dbgClient.absPath(self.fix_frame_filename(fr)),
204 fr.f_lineno, 205 fr.f_lineno,
205 fr.f_code.co_name) 206 fr.f_code.co_name)
206 fr = toFrame 207 fr = toFrame
304 if not (frame.f_code.co_flags & CO_GENERATOR and 305 if not (frame.f_code.co_flags & CO_GENERATOR and
305 arg[0] is StopIteration and arg[2] is None): 306 arg[0] is StopIteration and arg[2] is None):
306 self.user_exception(frame, arg) 307 self.user_exception(frame, arg)
307 if self.quitting: 308 if self.quitting:
308 raise bdb.BdbQuit 309 raise bdb.BdbQuit
310
309 # Stop at the StopIteration or GeneratorExit exception when the user 311 # Stop at the StopIteration or GeneratorExit exception when the user
310 # has set stopframe in a generator by issuing a return command, or a 312 # has set stopframe in a generator by issuing a return command, or a
311 # next/until command at the last statement in the generator before the 313 # next/until command at the last statement in the generator before the
312 # exception. 314 # exception.
313 elif (self.stopframe and frame is not self.stopframe and 315 elif (self.stopframe and frame is not self.stopframe and
521 # The line itself has no breakpoint, but maybe the line is the 523 # The line itself has no breakpoint, but maybe the line is the
522 # first line of a function with breakpoint set by function 524 # first line of a function with breakpoint set by function
523 # name. 525 # name.
524 lineno = frame.f_code.co_firstlineno 526 lineno = frame.f_code.co_firstlineno
525 if lineno in self.breaks[filename]: 527 if lineno in self.breaks[filename]:
526 # flag says ok to delete temp. bp 528 # flag says ok to delete temp. breakpoint
527 (bp, flag) = bdb.effective(filename, lineno, frame) 529 (bp, flag) = bdb.effective(filename, lineno, frame)
528 if bp: 530 if bp:
529 self.currentbp = bp.number 531 self.currentbp = bp.number
530 if (flag and bp.temporary): 532 if (flag and bp.temporary):
531 self.__do_clear(filename, lineno) 533 self.__do_clear(filename, lineno)
532 return True 534 return True
533 535
534 if "Watch" in self.breaks: 536 if "Watch" in self.breaks:
535 # flag says ok to delete temp. bp 537 # flag says ok to delete temp. watch
536 (bp, flag) = self.__effective(frame) 538 (bp, flag) = self.__effective(frame)
537 if bp: 539 if bp:
538 self.currentbp = bp.number 540 self.currentbp = bp.number
539 if (flag and bp.temporary): 541 if (flag and bp.temporary):
540 self.__do_clearWatch(bp.cond) 542 self.__do_clearWatch(bp.cond)
705 return 707 return
706 708
707 if exctype in [SystemExit, bdb.BdbQuit]: 709 if exctype in [SystemExit, bdb.BdbQuit]:
708 atexit._run_exitfuncs() 710 atexit._run_exitfuncs()
709 if excval is None: 711 if excval is None:
710 excval = 0 712 exitcode = 0
711 message = "" 713 message = ""
712 elif isinstance(excval, str): 714 elif isinstance(excval, str):
713 excval = 1 715 exitcode = 1
714 message = excval 716 message = excval
715 elif isinstance(excval, bytes): 717 elif isinstance(excval, bytes):
716 excval = 1 718 exitcode = 1
717 message = excval.decode() 719 message = excval.decode()
718 if isinstance(excval, int): 720 elif isinstance(excval, int):
719 self._dbgClient.progTerminated(excval, message) 721 exitcode = excval
722 message = ""
723 elif isinstance(excval, SystemExit):
724 code = excval.code
725 if isinstance(code, str):
726 exitcode = 1
727 message = code
728 elif isinstance(code, bytes):
729 exitcode = 1
730 message = code.decode()
731 elif isinstance(code, int):
732 exitcode = code
733 message = ""
734 else:
735 exitcode = 1
736 message = str(code)
720 else: 737 else:
721 self._dbgClient.progTerminated(excval.code, "") 738 exitcode = 1
739 message = str(excval)
740 self._dbgClient.progTerminated(exitcode, message)
722 return 741 return
723 742
724 if exctype in [SyntaxError, IndentationError]: 743 if exctype in [SyntaxError, IndentationError]:
725 try: 744 try:
726 message = str(excval) 745 message = str(excval)

eric ide

mercurial