but that doesn't match a value being passed a standard Python 3 string (literal) of type str created via str(...). Moreover, I couldn't come up with a way to construct a "unicode string" in Python 3 that matches PyUnicode_Check in the C API. I'm utterly confused. I could try converting it to a bytes object and use the functions in bytesobject.h but that doesn't seem right either?
Have anybody tried extracting a
char*
from a Python 3PyObject*
having type namestr
? Normal strings in Python 3 have type namestr
in the C API.For Python 2 one can use
PyString_Check()
andPyString_AsStringAndSize
present in the headerstringobject.h
.For Python 3 this header is not present, instead there is
bytesobject
andunicodeobject.h
. For the latter, using D, I put togetherbut that doesn't match a
value
being passed a standard Python 3 string (literal) of typestr
created viastr(...)
. Moreover, I couldn't come up with a way to construct a "unicode string" in Python 3 that matchesPyUnicode_Check
in the C API. I'm utterly confused. I could try converting it to a bytes object and use the functions inbytesobject.h
but that doesn't seem right either?I've also tried
but that fails complaining about obj not being of type
bytes
.