634 self._dbgClient.progTerminated(excval) |
634 self._dbgClient.progTerminated(excval) |
635 else: |
635 else: |
636 self._dbgClient.progTerminated(excval.code) |
636 self._dbgClient.progTerminated(excval.code) |
637 return |
637 return |
638 |
638 |
639 elif exctype in [SyntaxError, IndentationError]: |
639 if exctype in [SyntaxError, IndentationError]: |
640 try: |
640 try: |
641 message, (filename, linenr, charnr, text) = excval |
641 message, (filename, linenr, charnr, text) = excval |
642 except ValueError: |
642 except ValueError: |
643 exclist = [] |
643 exclist = [] |
|
644 realSyntaxError = True |
644 else: |
645 else: |
645 exclist = [message, [filename, linenr, charnr]] |
646 exclist = [message, [filename, linenr, charnr]] |
|
647 realSyntaxError = os.path.exists(filename) |
646 |
648 |
647 self._dbgClient.write("%s%s\n" % (ResponseSyntax, unicode(exclist))) |
649 if realSyntaxError: |
648 |
650 self._dbgClient.write("%s%s\n" % (ResponseSyntax, unicode(exclist))) |
|
651 self._dbgClient.eventLoop() |
|
652 return |
|
653 |
|
654 if type(exctype) in [types.ClassType, # Python up to 2.4 |
|
655 types.TypeType]: # Python 2.5+ |
|
656 exctype = exctype.__name__ |
|
657 |
|
658 if excval is None: |
|
659 excval = '' |
|
660 |
|
661 if unhandled: |
|
662 exctypetxt = "unhandled %s" % unicode(exctype) |
649 else: |
663 else: |
650 if type(exctype) in [types.ClassType, # Python up to 2.4 |
664 exctypetxt = unicode(exctype) |
651 types.TypeType]: # Python 2.5+ |
665 try: |
652 exctype = exctype.__name__ |
666 exclist = [exctypetxt, |
|
667 unicode(excval).encode(self._dbgClient.getCoding())] |
|
668 except TypeError: |
|
669 exclist = [exctypetxt, str(excval)] |
|
670 |
|
671 if exctb: |
|
672 frlist = self.__extract_stack(exctb) |
|
673 frlist.reverse() |
653 |
674 |
654 if excval is None: |
675 self.currentFrame = frlist[0] |
655 excval = '' |
676 self.currentFrameLocals = frlist[0].f_locals |
|
677 # remember the locals because it is reinitialized when accessed |
656 |
678 |
657 if unhandled: |
679 for fr in frlist: |
658 exctypetxt = "unhandled %s" % unicode(exctype) |
680 filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) |
659 else: |
681 |
660 exctypetxt = unicode(exctype) |
682 if os.path.basename(filename).startswith("DebugClient") or \ |
661 try: |
683 os.path.basename(filename) == "bdb.py": |
662 exclist = [exctypetxt, |
684 break |
663 unicode(excval).encode(self._dbgClient.getCoding())] |
685 |
664 except TypeError: |
686 linenr = fr.f_lineno |
665 exclist = [exctypetxt, str(excval)] |
687 ffunc = fr.f_code.co_name |
666 |
688 |
667 if exctb: |
689 if ffunc == '?': |
668 frlist = self.__extract_stack(exctb) |
690 ffunc = '' |
669 frlist.reverse() |
691 |
670 |
692 if ffunc and not ffunc.startswith("<"): |
671 self.currentFrame = frlist[0] |
693 argInfo = inspect.getargvalues(fr) |
672 self.currentFrameLocals = frlist[0].f_locals |
694 fargs = inspect.formatargvalues(argInfo[0], argInfo[1], |
673 # remember the locals because it is reinitialized when accessed |
695 argInfo[2], argInfo[3]) |
674 |
696 else: |
675 for fr in frlist: |
697 fargs = "" |
676 filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) |
698 |
677 |
699 exclist.append([filename, linenr, ffunc, fargs]) |
678 if os.path.basename(filename).startswith("DebugClient") or \ |
700 |
679 os.path.basename(filename) == "bdb.py": |
701 self._dbgClient.write("%s%s\n" % (ResponseException, unicode(exclist))) |
680 break |
702 |
681 |
703 if exctb is None: |
682 linenr = fr.f_lineno |
704 return |
683 ffunc = fr.f_code.co_name |
|
684 |
|
685 if ffunc == '?': |
|
686 ffunc = '' |
|
687 |
|
688 if ffunc and not ffunc.startswith("<"): |
|
689 argInfo = inspect.getargvalues(fr) |
|
690 fargs = inspect.formatargvalues(argInfo[0], argInfo[1], |
|
691 argInfo[2], argInfo[3]) |
|
692 else: |
|
693 fargs = "" |
|
694 |
|
695 exclist.append([filename, linenr, ffunc, fargs]) |
|
696 |
|
697 self._dbgClient.write("%s%s\n" % (ResponseException, unicode(exclist))) |
|
698 |
|
699 if exctb is None: |
|
700 return |
|
701 |
705 |
702 self._dbgClient.eventLoop() |
706 self._dbgClient.eventLoop() |
703 |
707 |
704 def __extract_stack(self, exctb): |
708 def __extract_stack(self, exctb): |
705 """ |
709 """ |