Fixed an issue related to the different ways Python2 and Python3 display unicode strings and causing the Python2 debugger interface to fail with a stack trace.

Sat, 30 Oct 2010 19:13:41 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 30 Oct 2010 19:13:41 +0200
changeset 711
8cd4f7a574a2
parent 710
5a18249d68aa
child 713
7ef4e217ec22

Fixed an issue related to the different ways Python2 and Python3 display unicode strings and causing the Python2 debugger interface to fail with a stack trace.

Debugger/DebuggerInterfacePython.py file | annotate | diff | comparison | revisions
--- a/Debugger/DebuggerInterfacePython.py	Fri Oct 29 19:09:37 2010 +0200
+++ b/Debugger/DebuggerInterfacePython.py	Sat Oct 30 19:13:41 2010 +0200
@@ -9,6 +9,7 @@
 
 import sys
 import os
+import re
 
 from PyQt4.QtCore import *
 from PyQt4.QtGui import QInputDialog
@@ -73,6 +74,8 @@
         
         self.codec = QTextCodec.codecForName(Preferences.getSystem("StringEncoding"))
         
+        self.__unicodeRe = re.compile(r"""\bu(["'])""")
+        
         if passive:
             # set translation function
             if Preferences.getDebugger("PathTranslation"):
@@ -761,9 +764,10 @@
                 
             if boc >= 0 and eoc > boc:
                 resp = line[boc:eoc]
+                evalArg = self.__unicodeRe.sub(r"\1", line[eoc:-1])
                 
                 if resp == ResponseLine or resp == ResponseStack:
-                    stack = eval(line[eoc:-1])
+                    stack = eval(evalArg)
                     for s in stack:
                         s[0] = self.translate(s[0], True)
                     cf = stack[0]
@@ -777,7 +781,7 @@
                     continue
                 
                 if resp == ResponseThreadList:
-                    currentId, threadList = eval(line[eoc:-1])
+                    currentId, threadList = eval(evalArg)
                     self.debugServer.signalClientThreadList(currentId, threadList)
                     continue
                 
@@ -786,7 +790,7 @@
                     continue
                 
                 if resp == ResponseVariables:
-                    vlist = eval(line[eoc:-1])
+                    vlist = eval(evalArg)
                     scope = vlist[0]
                     try:
                         variables = vlist[1:]
@@ -796,7 +800,7 @@
                     continue
                 
                 if resp == ResponseVariable:
-                    vlist = eval(line[eoc:-1])
+                    vlist = eval(evalArg)
                     scope = vlist[0]
                     try:
                         variables = vlist[1:]
@@ -814,8 +818,7 @@
                     continue
                 
                 if resp == ResponseException:
-                    exc = line[eoc:-1]
-                    exc = self.translate(exc, True)
+                    exc = self.translate(evalArg, True)
                     try:
                         exclist = eval(exc)
                         exctype = exclist[0]
@@ -829,8 +832,7 @@
                     continue
                 
                 if resp == ResponseSyntax:
-                    exc = line[eoc:-1]
-                    exc = self.translate(exc, True)
+                    exc = self.translate(evalArg, True)
                     try:
                         message, (fn, ln, cn) = eval(exc)
                         if fn is None:
@@ -846,69 +848,67 @@
                     continue
                 
                 if resp == ResponseExit:
-                    self.debugServer.signalClientExit(line[eoc:-1])
+                    self.debugServer.signalClientExit(evalArg)
                     continue
                 
                 if resp == ResponseClearBreak:
-                    fn, lineno = line[eoc:-1].split(',')
+                    fn, lineno = evalArg.split(',')
                     lineno = int(lineno)
                     fn = self.translate(fn, True)
                     self.debugServer.signalClientClearBreak(fn, lineno)
                     continue
                 
                 if resp == ResponseBPConditionError:
-                    fn, lineno = line[eoc:-1].split(',')
+                    fn, lineno = evalArg.split(',')
                     lineno = int(lineno)
                     fn = self.translate(fn, True)
                     self.debugServer.signalClientBreakConditionError(fn, lineno)
                     continue
                 
                 if resp == ResponseClearWatch:
-                    cond = line[eoc:-1]
-                    self.debugServer.signalClientClearWatch(cond)
+                    self.debugServer.signalClientClearWatch(evalArg)
                     continue
                 
                 if resp == ResponseWPConditionError:
-                    cond = line[eoc:-1]
-                    self.debugServer.signalClientWatchConditionError(cond)
+                    self.debugServer.signalClientWatchConditionError(evalArg)
                     continue
                 
                 if resp == ResponseRaw:
-                    prompt, echo = eval(line[eoc:-1])
+                    prompt, echo = eval(evalArg)
                     self.debugServer.signalClientRawInput(prompt, echo)
                     continue
                 
                 if resp == ResponseBanner:
-                    version, platform, dbgclient = eval(line[eoc:-1])
+                    version, platform, dbgclient = eval(evalArg)
                     self.debugServer.signalClientBanner(version, platform, dbgclient)
                     continue
                 
                 if resp == ResponseCapabilities:
-                    cap, clType = eval(line[eoc:-1])
+                    cap, clType = eval(evalArg)
                     self.clientCapabilities = cap
                     self.debugServer.signalClientCapabilities(cap, clType)
                     continue
                 
                 if resp == ResponseCompletion:
-                    clstring, text = line[eoc:-1].split('||')
+                    clstring, text = evalArg.split('||')
                     cl = eval(clstring)
                     self.debugServer.signalClientCompletionList(cl, text)
                     continue
                 
                 if resp == PassiveStartup:
-                    fn, exc = line[eoc:-1].split('|')
+                    fn, exc = evalArg.split('|')
                     exc = bool(exc)
                     fn = self.translate(fn, True)
                     self.debugServer.passiveStartUp(fn, exc)
                     continue
                 
                 if resp == ResponseUTPrepared:
-                    res, exc_type, exc_value = eval(line[eoc:-1])
+                    res, exc_type, exc_value = eval(evalArg)
                     self.debugServer.clientUtPrepared(res, exc_type, exc_value)
                     continue
                 
                 if resp == ResponseUTStartTest:
-                    testname, doc = eval(line[eoc:-1])
+                    testname, doc = eval(evalArg)
                     self.debugServer.clientUtStartTest(testname, doc)
                     continue
                 
@@ -917,12 +917,12 @@
                     continue
                 
                 if resp == ResponseUTTestFailed:
-                    testname, traceback = eval(line[eoc:-1])
+                    testname, traceback = eval(evalArg)
                     self.debugServer.clientUtTestFailed(testname, traceback)
                     continue
                 
                 if resp == ResponseUTTestErrored:
-                    testname, traceback = eval(line[eoc:-1])
+                    testname, traceback = eval(evalArg)
                     self.debugServer.clientUtTestErrored(testname, traceback)
                     continue
                 
@@ -933,7 +933,7 @@
                 if resp == RequestForkTo:
                     self.__askForkTo()
                     continue
-                
+            
             self.debugServer.signalClientOutput(line)
 
     def __sendCommand(self, cmd):
@@ -945,4 +945,4 @@
         if self.qsock is not None:
             self.qsock.write(cmd.encode('utf8'))
         else:
-            self.queue.append(cmd)
\ No newline at end of file
+            self.queue.append(cmd)

eric ide

mercurial