Commit ae137ef7 authored by Mark Florisson's avatar Mark Florisson

Debugger: Python 3 compatibility testsuite

parent d8647256
......@@ -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
......
......@@ -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):
......
......@@ -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(
......
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