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
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):
except RuntimeError:
# Python 3
PyString_FromStringAndSize = ('PyUnicode%s_FromStringAndSize' %
- (get_inferior_unicode_postfix,))
+ (get_inferior_unicode_postfix(),))
try:
result = gdb.parse_and_eval(