git://github.com/pawelz/ekg2.git branch master: commit a31760d809e3e464e5e26dc42de97a5e1c9ec53f Author: Paweł Zuzelski Date: Fri Jan 22 01:17:47 2010 +0100 fixed conversion from long to PyObject The false assumption sizeof(long) == size(void*) exists where PyInt_FromLong is used to represent a pointer. The safe Python call for this is PyLong_FromVoidPtr. (On platforms where the above assumption *is* true a PyInt is returned as before so there is no effective change.) This fixes segfault on x86_64 machines. The simplest way to reproduce segfault is to load the following python script: import ekg def reply(session, uid, type, text, stime, ignore_level): ekg.command("/msg "+uid+" "+text) ekg.handler_bind('protocol-message', reply) and receive any message. diff --git a/plugins/python/python.c b/plugins/python/python.c index 272ad4f..9a33049 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -222,7 +222,7 @@ int python_query(script_t *scr, script_query_t *scr_que, void **args) PyObject *w = NULL; switch ( scr_que->argv_type[i] ) { case (QUERY_ARG_INT): - w = PyInt_FromLong((long) *(int *) args[i] ); + w = PyLong_FromVoidPtr( args[i] ); break; case (QUERY_ARG_CHARP): { char *tmp = *(char **) args[i];