basic type creation (C->python)

Michael Hudson mwh at
Thu Aug 22 15:17:25 CEST 2002

Dave Marotti <landshark at> writes:

> I was going through the "noddy" example of creating a new type for
> python and ran into some difficulties.
> Everything seems to compile ok (I use "python build"), but
> when I run python and attempt to import noddy, I get this:
> [landshark at burrito ~/pytype/build/lib.linux-i686-1.5]$ python
> Python 1.5.2 (#1, Apr  3 2002, 18:16:26)  

Here's the problem.  PyObject_Del didn't exist in 1.5.2.  You should
have got warnings when compiling.

> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> ImportError: ./ undefined symbol: PyObject_Del
> >>>
> Just as it says, and nm on the file shows all Py* methods as
> undefined.  I'm assuming this is normal since they are in the python
> executable... but how do I get around this so I can use the new type?

You could replace the call to PyObject_Del with a call to PyMem_Free,
but better would be to grab the pymemcompat.h header from*checkout*/python/python/dist/src/Misc/pymemcompat.h?rev=1.2

and #include it into the noddymodule.c source.  The advantage of the
latter is that the code should then work with all versions of Python
from 1.5.2 to 2.3 and hopefully beyond (after a recompile).


  Just put the user directories on a 486 with deadrat7.1 and turn the
  Octane into the afforementioned beer fridge and keep it in your
  office. The lusers won't notice the difference, except that you're
  more cheery during office hours.              -- Pim van Riezen, asr

More information about the Python-list mailing list