[Q]An error with my module in C

Robert Kern robert.kern at gmail.com
Tue Oct 3 06:35:05 CEST 2006


Jia,Lu wrote:
> hello,all.
> 
>   I wrote a module in C as below, BUT msg() method cannot work
> allright.
> 
> #include <stdio.h>
> #include <python2.4/Python.h>

This isn't related to your error, but you should include Python.h before other 
headers, and it should be just this:

#include "Python.h"

distutils will make sure the include path is correct.

> static PyObject *Roka_msg(PyObject *self,PyObject *args)
> {
> 	printf("Roka Python lib. Version 1.0\n");
> }

You actually need to return a PyObject* here. Specifically, you want to return 
None after incrementing its reference count:

   Py_INCREF(Py_None);
   return Py_None;

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list