diff -r ae7c9d9f3b4a -r f36b757378f1 DebugClients/Python/DebugBase.py --- a/DebugClients/Python/DebugBase.py Thu Sep 19 19:23:08 2013 +0200 +++ b/DebugClients/Python/DebugBase.py Sun Sep 22 16:03:25 2013 +0200 @@ -636,68 +636,72 @@ self._dbgClient.progTerminated(excval.code) return - elif exctype in [SyntaxError, IndentationError]: + if exctype in [SyntaxError, IndentationError]: try: message, (filename, linenr, charnr, text) = excval except ValueError: exclist = [] + realSyntaxError = True else: exclist = [message, [filename, linenr, charnr]] - - self._dbgClient.write("%s%s\n" % (ResponseSyntax, unicode(exclist))) - - else: - if type(exctype) in [types.ClassType, # Python up to 2.4 - types.TypeType]: # Python 2.5+ - exctype = exctype.__name__ - - if excval is None: - excval = '' + realSyntaxError = os.path.exists(filename) - if unhandled: - exctypetxt = "unhandled %s" % unicode(exctype) - else: - exctypetxt = unicode(exctype) - try: - exclist = [exctypetxt, - unicode(excval).encode(self._dbgClient.getCoding())] - except TypeError: - exclist = [exctypetxt, str(excval)] + if realSyntaxError: + self._dbgClient.write("%s%s\n" % (ResponseSyntax, unicode(exclist))) + self._dbgClient.eventLoop() + return + + if type(exctype) in [types.ClassType, # Python up to 2.4 + types.TypeType]: # Python 2.5+ + exctype = exctype.__name__ + + if excval is None: + excval = '' + + if unhandled: + exctypetxt = "unhandled %s" % unicode(exctype) + else: + exctypetxt = unicode(exctype) + try: + exclist = [exctypetxt, + unicode(excval).encode(self._dbgClient.getCoding())] + except TypeError: + exclist = [exctypetxt, str(excval)] + + if exctb: + frlist = self.__extract_stack(exctb) + frlist.reverse() - if exctb: - frlist = self.__extract_stack(exctb) - frlist.reverse() + self.currentFrame = frlist[0] + self.currentFrameLocals = frlist[0].f_locals + # remember the locals because it is reinitialized when accessed + + for fr in frlist: + filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) - self.currentFrame = frlist[0] - self.currentFrameLocals = frlist[0].f_locals - # remember the locals because it is reinitialized when accessed + if os.path.basename(filename).startswith("DebugClient") or \ + os.path.basename(filename) == "bdb.py": + break + + linenr = fr.f_lineno + ffunc = fr.f_code.co_name + + if ffunc == '?': + ffunc = '' - for fr in frlist: - filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) - - if os.path.basename(filename).startswith("DebugClient") or \ - os.path.basename(filename) == "bdb.py": - break - - linenr = fr.f_lineno - ffunc = fr.f_code.co_name - - if ffunc == '?': - ffunc = '' - - if ffunc and not ffunc.startswith("<"): - argInfo = inspect.getargvalues(fr) - fargs = inspect.formatargvalues(argInfo[0], argInfo[1], - argInfo[2], argInfo[3]) - else: - fargs = "" - - exclist.append([filename, linenr, ffunc, fargs]) - - self._dbgClient.write("%s%s\n" % (ResponseException, unicode(exclist))) - - if exctb is None: - return + if ffunc and not ffunc.startswith("<"): + argInfo = inspect.getargvalues(fr) + fargs = inspect.formatargvalues(argInfo[0], argInfo[1], + argInfo[2], argInfo[3]) + else: + fargs = "" + + exclist.append([filename, linenr, ffunc, fargs]) + + self._dbgClient.write("%s%s\n" % (ResponseException, unicode(exclist))) + + if exctb is None: + return self._dbgClient.eventLoop()