I am writing a python extension in C and I am trying to pass a bytes object to my function. Obviously the 's' token is for strings; I have tried 'O', 'N', and a few others with no luck. Is there a token I can use to parse a bytes object? If not is there an alternative method to parse bytes objects?
static PyObject *test(PyObject *self, PyObject *args)
{
char *dev;
uint8_t *key;
if(!PyArg_ParseTuple(args, "ss", &dev, &key))
return NULL;
printf("%s\n", dev);
for (int i = 0; i < 32; i++)
{
printf("Val %d: %d\n", i, key[i]);
}
Py_RETURN_NONE;
}
Calling from python: test(b"device", f.read(32)).
b"device"instead.