PyCFunction_New requires a pointer to a static PyMethodDef?

Ben Sizer kylotan at gmail.com
Tue Jan 9 07:14:34 EST 2007


In following the example given at
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/54352>, I find
that if I instead try to create PyMethodDef instances on the stack and
create methods that way, rather than providing pointers to a static
array of them, executing the method later raises an exception from
PyCFunction_Call.

Is it required that the PyMethodDef persists throughout the execution
of the Python program? If so, why isn't the information just copied
instead? I was hoping to just create a temporary PyMethodDef on the
stack purely for the duration of creating the method.

(Google doesn't find any instance of "PyCFunction_Call" on
docs.python.org. This might explain the Cookbook's comment that "one
hardly ever sees Python class objects built in C extensions"!)

-- 
Ben Sizer




More information about the Python-list mailing list