passing callback function to c-extension

Skip Montanaro skip at pobox.com
Wed Jan 14 12:02:17 EST 2004


    Diez> I'm now looking for a way to ensure that the passed object is
    Diez> actually a callable one 

Try it and see.  If an exception is raised, just return NULL.  The
appropriate exception stuff will have been set.

Alternatively, you can test the value of

    PyCallable_Check(obj)

to see if obj is really callable and do your own error recovery.

    - and how to throw exceptions. 

The C API manual is your friend here:

    http://www.python.org/doc/api/api.html

Search for "exception".

Skip




More information about the Python-list mailing list