What's wrong?

Fredrik Lundh fredrik at pythonware.com
Wed Jan 25 04:45:52 EST 2006


"kishkin" wrote:

> :)) O? course it PyCallable_Check there!!! :)) And error is that
> PyCallable_Check returned 0.
>
> power.c compiles without errors.
>
> error is here:
>  -----------------------------------
> [kishkin at linuxa-miho 1]$ make -f makefile.power
> gcc power.c -g -I/usr/local/include/python2.4 -fpic -shared -o power.so
> [kishkin at linuxa-miho 1]$ python power.py
> Exception exceptions.TypeError: 'argument list must be a tuple' in
> 'garbage collection' ignored
> Fatal Python error: enexpected exception during garbage collection

enexpected?  are you typing things in by hand, or does your computer
have a bad RAM chip ?

> Aborted
>  -----------------------------------

try changing

    result = Py_BuildValue("i", num*num);
    PyEval_CallObject(temp, result);
    Py_DECREF(result);

to

    result = Py_BuildValue("(i)", num*num);
    PyEval_CallObject(temp, result);
    Py_DECREF(result);

or, more convenient

    result = PyObject_CallFunction(temp, "i", num*num);
    if (!result)
        return NULL;

(note that you don't really need to check for callables; the CallFunction
API will do that for you, and generate a proper exception if you pass in
the wrong thing).

</F>






More information about the Python-list mailing list