PyModule/.dll/thread error
Mitja Semolic
mitjase at hotmail.com
Thu Aug 10 15:38:07 EDT 2000
I am just tring to build a simple dll module. Is there a sample source dll
module that i could download?
When the module is imported from python i get the error: Fatal Python
error: PyThreadState_Get: no current thread.
The code:
#include "stdafx.h"
#include <Python.h>
extern "C" __declspec(dllexport) void initmodx(void);
PyObject* dot(PyObject* self, PyObject* args)
{
float f1, f2;
if (!PyArg_ParseTuple(args, "ff", &f1, &f2))
{
PyErr_SetString(PyExc_TypeError, "invalid params");
return NULL;
}
/* modx.cpp*/
return Py_BuildValue("f", f1*f2);
}
static PyMethodDef ModxMethods[]=
{
{"dot", dot, METH_VARARGS},
{NULL, NULL}
};
__declspec(dllexport) void initmodx()
{
(void) Py_InitModule("modx", ModxMethods);
}
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID
lpReserved)
{
return TRUE;
}
More information about the Python-list
mailing list