[Numpy-discussion] __array__struct__: about using PyCapsule instead of PyCObject for Python 2.7

Sturla Molden sturla@molden...
Thu Jul 1 22:52:10 CDT 2010


Lisandro Dalcin skrev:
> No, no sarcasm at all! I just realized that PyCObject were
> (pending)deprecated in 2.7 ... Anyway. let me say I'm so annoyed and
> upset as you.
>
>   
PyCapsule should be used instead. It has two main advantages over 
PyCObject: First, it associates a 'name' with the void pointer, to 
provide some sort of type safety. (The 'name' could have been named 
'password' to make its intention clear.) Second, the PyCapsule API makes 
it easier to implement destructors.

PyCObject is a severe security hole and stability problem. It can crash 
the interpreter or run exploit code, as no checks are made before 
destructors are executed.

PyCObject will never be missed. And personally I am glad it was 
deprecated because it should be avoided. It is better to include a 
backport of PyCapsule than continue to use PyCObject for Python 2.6, 2.5 
and 2.4.

Sturla


More information about the NumPy-Discussion mailing list