I think that ``buf`` and ``obj`` are switched: https://docs.python.org/3.3/c-api/buffer.html#Py_buffer