If it makes a difference, I am interested in an answer regarding Python 3.
The docs state (here and here) that PyBuffer_Release() should be called after PyArg_Parse*() with s*, y*.
Nothing of the sort is written about Py_BuildValue(). Is it an oversight, or in case of Py_BuildValue() a simple Py_DECREF() is enough?
Here is my specific case:
uint8_t buf = (uint8_t *)malloc(bufSize);
PyObject *pyBuf = Py_BuildValue("y#", (char *)buf, bufSize);
free(buf);
// do something with pyBuf
// maybe a PyBuffer_Release(get_underlying_buffer(pyBuf)) here?
Py_DECREF(pyBuf);