Python 2.2.1 DLL extension causes "abnormal program termination"

Fredrik Lundh fredrik at
Thu Sep 1 16:47:55 CEST 2005

Hugh wrote:

> Apologies if this has already been answered in here and I can't find
> it, but can anyone help with this problem?
> I hope the example code and comments state clearly enough what is
> happening, but if not, please ask me for further information.
> Thank in advance for any help.

> #   static PyObject* dummy(PyObject* self, PyObject* args)
> #   {
> #   return Py_None;
> #   }

C functions must return an "owned" reference.  or in other words, since
Py_None is an existing object, you need to increment the reference count
before returning it:

    return Py_None;

or, better, but only works in recent Pythons:


for more on reference counting and object ownership, see:


More information about the Python-list mailing list