ctypes + PyBuffer?

Chris Barker asked about having a PEP 3118 format handler for PyOpenGL. I've played around with this in the past, but always wound up with segfaults due to apparent double-free operations when using ctypes to do buffer work.  Basically, once I GetBuffer() into a buffer the deallocation of the buffer struct in ctypes seems to trigger a double-free.  Calling ReleaseBuffer() doesn't help, and neither does incref'ing the target object manually. So, anyone successfully used the PEP 3118 functions from ctypes? Anyone want to hit me over the head with a clue-stick as to what simple thing I'm missing in this test module?

Comments

  1. Andy Kittner

    Andy Kittner on 07/22/2013 3:11 p.m. #

    Hi, I just stumble upon this post in my Planet Python feed, since no one commented yet I thought I'd give it a try ;)

    The Problem appears to be the python2 structure definition in line 18
    According to my object.h (python-2.7.5) the smalltable field exists in python2 as well

    Using the python3 code path there it works in python2.7.5 and 3.3.2 for me (and even 2.6-something without the memoryview)

  2. Mike Fletcher

    Mike Fletcher on 07/23/2013 10:22 a.m. #

    Thanks Andy. It never occurred to me that the Python 2.7 C-api docs would just be wrong on the format of the structure. The Python 2.6 object.h header does seem to match the second code-path, so I guess I still need that, but with the modification to use Python 3.x style header of 2.7+ it does indeed work.

Comments are closed.

Pingbacks

Pingbacks are closed.

Trackbacks