Sat, 23 Jul 2016 14:15:43 +0200
Hide frames belonging to the debugger at a recursion exception.
--- a/DebugClients/Python/DebugBase.py Sat Jul 23 14:13:50 2016 +0200 +++ b/DebugClients/Python/DebugBase.py Sat Jul 23 14:15:43 2016 +0200 @@ -74,6 +74,9 @@ self.tracePythonLibs(0) + # Special handling of a recursion error + self.skipFrames = 0 + self.__isBroken = False self.cFrame = None @@ -652,6 +655,20 @@ self._dbgClient.eventLoop() return + self.skipFrames = 0 + if (exctype == RuntimeError and + str(excval).startswith('maximum recursion depth exceeded')): + excval = 'maximum recursion depth exceeded' + depth = 0 + tb = exctb + while tb: + tb = tb.tb_next + + if (tb and tb.tb_frame.f_code.co_name == 'trace_dispatch' and + __file__.startswith(tb.tb_frame.f_code.co_filename)): + depth = 1 + self.skipFrames += depth + if type(exctype) in [types.ClassType, # Python up to 2.4 types.TypeType]: # Python 2.5+ exctype = exctype.__name__ @@ -663,6 +680,7 @@ exctypetxt = "unhandled %s" % unicode(exctype) else: exctypetxt = unicode(exctype) + try: exclist = [exctypetxt, unicode(excval).encode(self._dbgClient.getCoding())] @@ -675,7 +693,7 @@ self.currentFrame = frlist[0] - for fr in frlist: + for fr in frlist[self.skipFrames:]: filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) if os.path.basename(filename).startswith("DebugClient") or \ @@ -706,6 +724,7 @@ return self._dbgClient.eventLoop() + self.skipFrames = 0 def __extract_stack(self, exctb): """
--- a/DebugClients/Python/DebugClientBase.py Sat Jul 23 14:13:50 2016 +0200 +++ b/DebugClients/Python/DebugClientBase.py Sat Jul 23 14:15:43 2016 +0200 @@ -1311,6 +1311,7 @@ if self.currentThread is None: return + frmnr += self.currentThread.skipFrames if scope == 0: self.framenr = frmnr @@ -1358,6 +1359,7 @@ if self.currentThread is None: return + frmnr += self.currentThread.skipFrames f = self.currentThread.getCurrentFrame() while f is not None and frmnr > 0:
--- a/DebugClients/Python3/DebugBase.py Sat Jul 23 14:13:50 2016 +0200 +++ b/DebugClients/Python3/DebugBase.py Sat Jul 23 14:15:43 2016 +0200 @@ -75,6 +75,9 @@ self.tracePythonLibs(0) + # Special handling of a recursion error + self.skipFrames = 0 + self.__isBroken = False self.cFrame = None @@ -680,6 +683,24 @@ self._dbgClient.eventLoop() return + self.skipFrames = 0 + if (exctype == RuntimeError and + str(excval).startswith('maximum recursion depth exceeded') or + sys.version_info >= (3, 5) and exctype == RecursionError): + excval = 'maximum recursion depth exceeded' + depth = 0 + tb = exctb + while tb: + tb = tb.tb_next + + if (tb and tb.tb_frame.f_code.co_name == 'trace_dispatch' and + __file__.startswith(tb.tb_frame.f_code.co_filename)): + depth = 1 + self.skipFrames += depth + + # always 1 if running without debugger + self.skipFrames = max(1, self.skipFrames) + exctype = self.__extractExceptionName(exctype) if excval is None: @@ -700,7 +721,7 @@ self.currentFrame = frlist[0] - for fr in frlist: + for fr in frlist[self.skipFrames:]: filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) if os.path.basename(filename).startswith("DebugClient") or \ @@ -733,7 +754,8 @@ return self._dbgClient.eventLoop() - + self.skipFrames = 0 + def __extractExceptionName(self, exctype): """ Private method to extract the exception name given the exception
--- a/DebugClients/Python3/DebugClientBase.py Sat Jul 23 14:13:50 2016 +0200 +++ b/DebugClients/Python3/DebugClientBase.py Sat Jul 23 14:15:43 2016 +0200 @@ -1316,6 +1316,7 @@ if self.currentThread is None: return + frmnr += self.currentThread.skipFrames if scope == 0: self.framenr = frmnr @@ -1363,6 +1364,7 @@ if self.currentThread is None: return + frmnr += self.currentThread.skipFrames f = self.currentThread.getCurrentFrame() while f is not None and frmnr > 0: