Sorry, this was not a good question [edited, revised, summarized and diagnosed].
I have a Python C-API that works with UUID. I will omit error checking, but it is done for all Python and internal functions. [edit: ok, sorry about that, my bad... see diagnose at bottom]
// Get the raw data through get_bytes method
bytes_uuid = PyObject_CallMethod(pyuuid, "get_bytes", NULL);
uuid.setBytes(PyString_AsString(bytes_uuid));
Py_DECREF(bytes_uuid);
This generally works as expected. To create UUIDs I use:
// Call constructor
PyObject *UUIDkwargs = Py_BuildValue ("{s:s#}", "bytes", uuid.getBytes(), 16);
PyObject *emptyArgs = PyTuple_New(0);
ret = PyObject_Call(uuidClass, emptyArgs, UUIDkwargs);
Py_DECREF(UUIDkwargs);
Py_DECREF(emptyArgs);
return ret;
(lots of things omitted for readibility).
It worked on most functions but not on a certain one, and failed in a chr() call from the UUID modue itself.
DIAGNOSE: I performed a call to PyObject_IsInstance, and checked for 0 but not for -1. The error was there, but uncatched, and the first call to built in failed. Well, not the first call. A chr() call with non-constant argument.
Because there was a lot of C code in between, I didn't expect that to be the problem.