Seg fault in python extension module

sam samschul at pacbell.net
Sat Jun 3 06:40:55 CEST 2006


Sorry, From MethodObject.h the 4th parameter is usually documented as
having a NULL, but is intended to be used for a documentation string
that will be available to the user under the various GUI IDE's such as
IDLE or PyWin32. I just wanted to point that out..

struct PyMethodDef {
    const char	*ml_name;	/* The name of the built-in function/method */
    PyCFunction  ml_meth;	/* The C function that implements it */
    int		 ml_flags;	/* Combination of METH_xxx flags, which mostly
				   describe the args expected by the C func */
    const char	*ml_doc;	/* The __doc__ attribute, or NULL */
};

Sam Schulenburg

John Machin wrote:
> On 3/06/2006 1:38 PM, sam wrote:
> > I recommend that you also replace the NULL after the METH_VARARGS with
> > a valid documentations string such as:
> >
> > static PyMethodDef modglMethods[] =
> >        {
> >          { (char *)"glVertex4f", _wrap_glVertex4f, METH_VARARGS, "My
> > Doc String"},
> >          { NULL, NULL, 0, NULL }
> >
> >       };
> >
>
> Lack of one is unlikely to have anything to do with the OP's segfault.
>
> |>>> repr(modgl.glVertex4f.__doc__)
> 'None'
> |>>>
>
> As to style, etiquette, and good citizenship in module extension
> writing, it might be better to give him some references, rather than
> mention just one point.
> 
> Cheers,
> John




More information about the Python-list mailing list