DebugClients/Python3/DebugBase.py

branch
jsonrpc
changeset 5124
1ba8ee313b57
parent 4830
f609a22f43bd
child 5125
eb1b3e0577e4
--- a/DebugClients/Python3/DebugBase.py	Thu Sep 01 18:28:27 2016 +0200
+++ b/DebugClients/Python3/DebugBase.py	Thu Sep 01 19:00:46 2016 +0200
@@ -15,8 +15,6 @@
 import ctypes
 from inspect import CO_GENERATOR
 
-from DebugProtocol import ResponseClearWatch, ResponseClearBreak, \
-    ResponseLine, ResponseSyntax, ResponseException, CallTrace
 from DebugUtilities import getargvalues, formatargvalues
 
 gRecursionLimit = 64
@@ -210,8 +208,7 @@
                         self._dbgClient.absPath(self.fix_frame_filename(fr)),
                         fr.f_lineno,
                         fr.f_code.co_name)
-                    self._dbgClient.write("{0}{1}@@{2}@@{3}\n".format(
-                        CallTrace, event[0], fromStr, toStr))
+                    self._dbgClient.sendCallTrace(event, fromStr, toStr)
     
     def trace_dispatch(self, frame, event, arg):
         """
@@ -445,7 +442,7 @@
         @param cond expression of the watch expression to be cleared (string)
         """
         self.clear_watch(cond)
-        self._dbgClient.write('{0}{1}\n'.format(ResponseClearWatch, cond))
+        self._dbgClient.sendClearTemporaryWatch(cond)
 
     def __effective(self, frame):
         """
@@ -582,8 +579,7 @@
         @param lineno linenumber of the bp
         """
         self.clear_break(filename, lineno)
-        self._dbgClient.write('{0}{1},{2:d}\n'.format(
-                              ResponseClearBreak, filename, lineno))
+        self._dbgClient.sendClearTemporaryBreakpoint(filename, lineno)
 
     def getStack(self):
         """
@@ -644,7 +640,9 @@
                 return
             fr = frame
             while (fr is not None and
-                    fr.f_code != self._dbgClient.handleLine.__code__):
+                   fr.f_code not in [
+                    self._dbgClient.handleLine.__code__,
+                    self._dbgClient.handleJsonCommand.__code__]):
                 self._dbgClient.mainFrame = fr
                 fr = fr.f_back
 
@@ -687,7 +685,7 @@
         
         self.__isBroken = True
         
-        self._dbgClient.write('{0}{1}\n'.format(ResponseLine, str(stack)))
+        self._dbgClient.sendResponseLine(stack)
         self._dbgClient.eventLoop()
 
     def user_exception(self, frame, excinfo, unhandled=False):
@@ -724,18 +722,19 @@
             try:
                 message = str(excval)
                 filename = excval.filename
-                linenr = excval.lineno
-                charnr = excval.offset
+                lineno = excval.lineno
+                charno = excval.offset
+                realSyntaxError = os.path.exists(filename)
             except (AttributeError, ValueError):
-                exclist = []
+                message = ""
+                filename = ""
+                lineno = 0
+                charno = 0
                 realSyntaxError = True
-            else:
-                exclist = [message, [filename, linenr, charnr]]
-                realSyntaxError = os.path.exists(filename)
             
             if realSyntaxError:
-                self._dbgClient.write("{0}{1}\n".format(
-                    ResponseSyntax, str(exclist)))
+                self._dbgClient.sendSyntaxError(
+                    message, filename, lineno, charno)
                 self._dbgClient.eventLoop()
                 return
         
@@ -748,11 +747,8 @@
             exctypetxt = "unhandled {0!s}".format(str(exctype))
         else:
             exctypetxt = str(exctype)
-        try:
-            exclist = [exctypetxt, str(excval)]
-        except TypeError:
-            exclist = [exctypetxt, str(excval)]
         
+        stack = []
         if exctb:
             frlist = self.__extract_stack(exctb)
             frlist.reverse()
@@ -783,10 +779,9 @@
                 else:
                     fargs = ""
                 
-                exclist.append([filename, linenr, ffunc, fargs])
+                stack.append([filename, linenr, ffunc, fargs])
         
-        self._dbgClient.write("{0}{1}\n".format(
-            ResponseException, str(exclist)))
+        self._dbgClient.sendException(exctypetxt, str(excval), stack)
         
         if exctb is None:
             return

eric ide

mercurial