DebugClients/Python3/DebugBase.py

changeset 2927
f36b757378f1
parent 2648
43a3bec63c09
child 2953
703452a2876f
equal deleted inserted replaced
2926:ae7c9d9f3b4a 2927:f36b757378f1
645 self._dbgClient.progTerminated(excval) 645 self._dbgClient.progTerminated(excval)
646 else: 646 else:
647 self._dbgClient.progTerminated(excval.code) 647 self._dbgClient.progTerminated(excval.code)
648 return 648 return
649 649
650 elif exctype in [SyntaxError, IndentationError]: 650 if exctype in [SyntaxError, IndentationError]:
651 try: 651 try:
652 message, (filename, linenr, charnr, text) = excval[0], excval[1] 652 message, (filename, linenr, charnr, text) = excval[0], excval[1]
653 except ValueError: 653 except ValueError:
654 exclist = [] 654 exclist = []
655 realSyntaxError = True
655 else: 656 else:
656 exclist = [message, [filename, linenr, charnr]] 657 exclist = [message, [filename, linenr, charnr]]
658 realSyntaxError = os.path.exists(filename)
657 659
658 self._dbgClient.write("{0}{1}\n".format(ResponseSyntax, str(exclist))) 660 if realSyntaxError:
659 661 self._dbgClient.write("{0}{1}\n".format(ResponseSyntax, str(exclist)))
662 self._dbgClient.eventLoop()
663 return
664
665 exctype = self.__extractExceptionName(exctype)
666
667 if excval is None:
668 excval = ''
669
670 if unhandled:
671 exctypetxt = "unhandled {0!s}".format(str(exctype))
660 else: 672 else:
661 exctype = self.__extractExceptionName(exctype) 673 exctypetxt = str(exctype)
674 try:
675 exclist = [exctypetxt, str(excval)]
676 except TypeError:
677 exclist = [exctypetxt, str(excval)]
678
679 if exctb:
680 frlist = self.__extract_stack(exctb)
681 frlist.reverse()
662 682
663 if excval is None: 683 self.currentFrame = frlist[0]
664 excval = '' 684 self.currentFrameLocals = frlist[0].f_locals
685 # remember the locals because it is reinitialized when accessed
665 686
666 if unhandled: 687 for fr in frlist:
667 exctypetxt = "unhandled {0!s}".format(str(exctype)) 688 filename = self._dbgClient.absPath(self.fix_frame_filename(fr))
668 else: 689
669 exctypetxt = str(exctype) 690 if os.path.basename(filename).startswith("DebugClient") or \
670 try: 691 os.path.basename(filename) == "bdb.py":
671 exclist = [exctypetxt, str(excval)] 692 break
672 except TypeError: 693
673 exclist = [exctypetxt, str(excval)] 694 linenr = fr.f_lineno
674 695 ffunc = fr.f_code.co_name
675 if exctb: 696
676 frlist = self.__extract_stack(exctb) 697 if ffunc == '?':
677 frlist.reverse() 698 ffunc = ''
678 699
679 self.currentFrame = frlist[0] 700 if ffunc and not ffunc.startswith("<"):
680 self.currentFrameLocals = frlist[0].f_locals 701 argInfo = inspect.getargvalues(fr)
681 # remember the locals because it is reinitialized when accessed 702 fargs = inspect.formatargvalues(argInfo.args, argInfo.varargs,
682 703 argInfo.keywords, argInfo.locals)
683 for fr in frlist: 704 else:
684 filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) 705 fargs = ""
685 706
686 if os.path.basename(filename).startswith("DebugClient") or \ 707 exclist.append([filename, linenr, ffunc, fargs])
687 os.path.basename(filename) == "bdb.py": 708
688 break 709 self._dbgClient.write("{0}{1}\n".format(ResponseException, str(exclist)))
689 710
690 linenr = fr.f_lineno 711 if exctb is None:
691 ffunc = fr.f_code.co_name 712 return
692 713
693 if ffunc == '?':
694 ffunc = ''
695
696 if ffunc and not ffunc.startswith("<"):
697 argInfo = inspect.getargvalues(fr)
698 fargs = inspect.formatargvalues(argInfo.args, argInfo.varargs,
699 argInfo.keywords, argInfo.locals)
700 else:
701 fargs = ""
702
703 exclist.append([filename, linenr, ffunc, fargs])
704
705 self._dbgClient.write("{0}{1}\n".format(ResponseException, str(exclist)))
706
707 if exctb is None:
708 return
709
710 self._dbgClient.eventLoop() 714 self._dbgClient.eventLoop()
711 715
712 def __extractExceptionName(self, exctype): 716 def __extractExceptionName(self, exctype):
713 """ 717 """
714 Private method to extract the exception name given the exception 718 Private method to extract the exception name given the exception

eric ide

mercurial