C extension problem (Solaris)

Fredrik Stenberg mail at fredriks.org
Thu Jun 28 16:35:54 CEST 2001


On 28 Jun 2001, Christopher A. Craig wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Though I have used the C API before, this was my first attempt at
> defining a new type with it, and I had a problem.  It works fine on my
> Linux/Intel box, but when I try to compile it on my Solaris 8
> UltraSPARC box it has an item in the module dictionary that contains a
> non-working reference to the subtraction routine.
>


Found the error, you forgot to end static PyMethodDef with {NULL,
NULL}.
i.e,

static PyMethodDef crat_methods[] = {
     {"_testgcd", crat_testgcd, METH_VARARGS, crat_testgcd_doc__},
     {"rational", Rational_new, METH_VARARGS, crat_Rational_doc__}

};

should be changed into,

static PyMethodDef crat_methods[] = {
     {"_testgcd", crat_testgcd, METH_VARARGS, crat_testgcd_doc__},
     {"rational", Rational_new, METH_VARARGS, crat_Rational_doc__},
     {NULL,NULL}

};

/princeps




More information about the Python-list mailing list