seg. fault with ext. module

Gorny gorny at
Sat Aug 25 11:20:30 CEST 2001


#include <Python.h>

static PyObject * makesock(PyObject *self, PyObject *args);

static PyMethodDef gforce_methods[] = {
 {"makesock", makesock, METH_VARARGS},

static PyObject * makesock(PyObject *self, PyObject *args)
 printf("Making socket...\n");
 return Py_None;

/* Initialization function for the module */
DL_EXPORT(void) initgforce(void)
 (void)Py_InitModule("gforce", gforce_methods);

>>> import gforce
>>> gforce.makesock()
Making socket...
>>> Ctrl-D
Segmentation fault
[gorny at darkstar ~/gforce]$

How do I prevent this. If i import other modules and close the python-shell
it'll not end with a segmentation fault, only if it's my module.. Do i have
to make an extra function in it, which `de-inits` the module..??


"When I was a little kid, I had this dream where a snake would rule and
the entire world (actually, I guess that a penguin was also part of the
but never mind)" -- Python Develper's Handbook, Andre Lessa

More information about the Python-list mailing list