def METHOD_NAME(self, string, gdbvar=None):
    if inferior_python_version < (3, 0):
        funcname = 'PyString_FromStringAndSize'
    else:
        funcname = 'PyBytes_FromStringAndSize'
    assert b'"' not in string
    # ensure double quotes
    code = '(PyObject *) %s("%s", %d)' % (funcname, string.decode('iso8859-1'), len(string))
    return self.pyobject_fromcode(code, gdbvar=gdbvar)