Hello,
I am working on my first python module based on a c program. The
module builds and installs OK using dist-utils, and imports fine into
python. However, when I try and use the one wrapper
("modgl.glVerte x4f(1, 2, 3, 1)") in the module, it seg faults.
Can anyone spot why this isn't working, or recommend a way to debug
these things.
Thanks,
Luke
#include <Python.h>
static PyObject *_wrap_glVertex 4f(PyObject *self, PyObject *args) {
PyObject *resultobj = NULL;
float arg1 ;
float arg2 ;
float arg3 ;
float arg4 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
if(!PyArg_Parse Tuple(args,(cha r
*)"OOOO:glVerte x4f",&obj0,&obj 1,&obj2,&obj3) ) goto fail;
{
arg1 = (float)(PyFloat _AsDouble(obj0) );
}
{
arg2 = (float)(PyFloat _AsDouble(obj1) );
}
{
arg3 = (float)(PyFloat _AsDouble(obj2) );
}
{
arg4 = (float)(PyFloat _AsDouble(obj3) );
}
glVertex4f(arg1 ,arg2,arg3,arg4 );
Py_INCREF(Py_No ne); resultobj = Py_None;
return resultobj;
fail:
return NULL;
};
static PyMethodDef modglMethods[] = {
{ (char *)"glVertex4f ", _wrap_glVertex4 f, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
PyMODINIT_FUNC modgl(void)
{
(void) Py_InitModule(" modgl", modglMethods);
};
int
main(int argc, char *argv[])
{
/* Pass argv[0] to the Python interpreter */
Py_SetProgramNa me(argv[0]);
/* Initialize the Python interpreter. Required. */
Py_Initialize() ;
/* Add a static module */
initmodgl();
return 0;
};
I am working on my first python module based on a c program. The
module builds and installs OK using dist-utils, and imports fine into
python. However, when I try and use the one wrapper
("modgl.glVerte x4f(1, 2, 3, 1)") in the module, it seg faults.
Can anyone spot why this isn't working, or recommend a way to debug
these things.
Thanks,
Luke
#include <Python.h>
static PyObject *_wrap_glVertex 4f(PyObject *self, PyObject *args) {
PyObject *resultobj = NULL;
float arg1 ;
float arg2 ;
float arg3 ;
float arg4 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
if(!PyArg_Parse Tuple(args,(cha r
*)"OOOO:glVerte x4f",&obj0,&obj 1,&obj2,&obj3) ) goto fail;
{
arg1 = (float)(PyFloat _AsDouble(obj0) );
}
{
arg2 = (float)(PyFloat _AsDouble(obj1) );
}
{
arg3 = (float)(PyFloat _AsDouble(obj2) );
}
{
arg4 = (float)(PyFloat _AsDouble(obj3) );
}
glVertex4f(arg1 ,arg2,arg3,arg4 );
Py_INCREF(Py_No ne); resultobj = Py_None;
return resultobj;
fail:
return NULL;
};
static PyMethodDef modglMethods[] = {
{ (char *)"glVertex4f ", _wrap_glVertex4 f, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
PyMODINIT_FUNC modgl(void)
{
(void) Py_InitModule(" modgl", modglMethods);
};
int
main(int argc, char *argv[])
{
/* Pass argv[0] to the Python interpreter */
Py_SetProgramNa me(argv[0]);
/* Initialize the Python interpreter. Required. */
Py_Initialize() ;
/* Add a static module */
initmodgl();
return 0;
};
Comment