[Python-Dev] Proposed: drop unnecessary "context" pointer from PyGetSetDef

Larry Hastings larry at hastings.org
Tue May 5 09:24:38 CEST 2009


Mark Dickinson wrote:
>> This doesn't sound right. The functions in the third party code will get
>> compiled with the wrong signature, so they can crash (or behave unexpectedly)
>> when called by Python.
>>     
> Yes, of course the signature of the getters and setters changes.  Please
> ignore me. :-)

If they don't use the closure field, then either they won't compile due 
to type mismatches or they'll work fine.  There's a lot of code in 
CPython that didn't need to be changed for my remove-closure patch; the 
functions didn't bother taking the "void * closure" that they were going 
to ignore anyway, and then they cast the function pointer in the 
PyGetSetDef to make the compiler shut up.  Worked fine.  And, in nearly 
all cases, the static PyGetSetDefs omit the closure member, which means 
C initializes them with a 0.


/larry/


More information about the Python-Dev mailing list