Debugger: Python 3 compatibility testsuite
authorMark Florisson <markflorisson88@gmail.com>
Mon, 24 Jan 2011 22:06:52 +0000 (23:06 +0100)
committerMark Florisson <markflorisson88@gmail.com>
Mon, 24 Jan 2011 22:06:52 +0000 (23:06 +0100)
Cython/Debugger/Tests/test_libcython_in_gdb.py
Cython/Debugger/Tests/test_libpython_in_gdb.py
Cython/Debugger/libpython.py

index 79de18581401cc9fa11deb33f6e527c7e97bd33b..6003be089905b9cc3dfd0c172dc048e4ec94131d 100644 (file)
@@ -232,7 +232,10 @@ class TestStep(DebugStepperTestCase):
         self.assertEqual(curframe.name(), 'PyEval_EvalFrameEx')
 
         pyframe = libpython.Frame(curframe).get_pyop()
-        self.assertEqual(str(pyframe.co_name), 'join')
+        # With Python 3 inferiors, pyframe.co_name will return a PyUnicodePtr,
+        # be compatible
+        frame_name = pyframe.co_name.proxyval(set())
+        self.assertEqual(frame_name, 'join')
         assert re.match(r'\d+    def join\(', result), result
 
 
index 5e0407d9ebd791337ed86a88b76e33bbc8b09cd6..e45adb22fdaf984fc80bdc4456e1c7f843ebeef7 100644 (file)
@@ -52,14 +52,14 @@ class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase):
 
     def alloc_bytestring(self, string, gdbvar=None):
         if inferior_python_version < (3, 0):
-            funcname = 'PyString_FromString'
+            funcname = 'PyString_FromStringAndSize'
         else:
-            funcname = 'PyBytes_FromString'
+            funcname = 'PyBytes_FromStringAndSize'
 
         assert '"' not in string
 
         # ensure double quotes
-        code = '(PyObject *) %s("%s")' % (funcname, string)
+        code = '(PyObject *) %s("%s", %d)' % (funcname, string, len(string))
         return self.pyobject_fromcode(code, gdbvar=gdbvar)
 
     def alloc_unicodestring(self, string, gdbvar=None):
index 769ecd066d142d56cc8fbf8722b2d1f5394852af..78534a490a7225d30742adecc59e315455bb1a74 100644 (file)
@@ -2281,7 +2281,7 @@ class PythonCodeExecutor(object):
         except RuntimeError:
             # Python 3
             PyString_FromStringAndSize = ('PyUnicode%s_FromStringAndSize' %
-                                               (get_inferior_unicode_postfix,))
+                                               (get_inferior_unicode_postfix(),))
 
         try:
             result = gdb.parse_and_eval(