Commit ae137ef7 authored by Mark Florisson's avatar Mark Florisson

Debugger: Python 3 compatibility testsuite

parent d8647256
...@@ -232,7 +232,10 @@ class TestStep(DebugStepperTestCase): ...@@ -232,7 +232,10 @@ class TestStep(DebugStepperTestCase):
self.assertEqual(curframe.name(), 'PyEval_EvalFrameEx') self.assertEqual(curframe.name(), 'PyEval_EvalFrameEx')
pyframe = libpython.Frame(curframe).get_pyop() 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 assert re.match(r'\d+ def join\(', result), result
......
...@@ -52,14 +52,14 @@ class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase): ...@@ -52,14 +52,14 @@ class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase):
def alloc_bytestring(self, string, gdbvar=None): def alloc_bytestring(self, string, gdbvar=None):
if inferior_python_version < (3, 0): if inferior_python_version < (3, 0):
funcname = 'PyString_FromString' funcname = 'PyString_FromStringAndSize'
else: else:
funcname = 'PyBytes_FromString' funcname = 'PyBytes_FromStringAndSize'
assert '"' not in string assert '"' not in string
# ensure double quotes # 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) return self.pyobject_fromcode(code, gdbvar=gdbvar)
def alloc_unicodestring(self, string, gdbvar=None): def alloc_unicodestring(self, string, gdbvar=None):
......
...@@ -2281,7 +2281,7 @@ class PythonCodeExecutor(object): ...@@ -2281,7 +2281,7 @@ class PythonCodeExecutor(object):
except RuntimeError: except RuntimeError:
# Python 3 # Python 3
PyString_FromStringAndSize = ('PyUnicode%s_FromStringAndSize' % PyString_FromStringAndSize = ('PyUnicode%s_FromStringAndSize' %
(get_inferior_unicode_postfix,)) (get_inferior_unicode_postfix(),))
try: try:
result = gdb.parse_and_eval( result = gdb.parse_and_eval(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment