0

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.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
MariusSiuram
  • 3,380
  • 1
  • 21
  • 40
  • `__builtin__.chr` doesn't call `isinstance`. What `chr` are you calling? – ecatmur Aug 05 '14 at 12:46
  • @ecatmur I'm not calling anyone here, this is code from the standard Python module uuid. I cannot see the relation between the problem, the error string and the actual code. – MariusSiuram Aug 05 '14 at 13:36
  • @ecatmur ok, the problem was a previous isinstance (from far far away). Couldn't trace it from so far, until i started everything from scratch and piece by piece. And then it strike. – MariusSiuram Aug 06 '14 at 06:33
  • This is not a discussion forum so please don't edit the title to "update" the question or to tag it. – Burhan Khalid Aug 06 '14 at 06:41

0 Answers0