exceptions from C
gmcm at hypernet.com
Wed Nov 3 18:11:01 CET 1999
Linux User wrote:
> I have been reading the section in the Lutz book on exceptions.
> It seems that exceptions are no longer simply string objects.
> Does this change the way exception are raised from C? If so
> where might I find info on how to do this?
bltinmodule.c has pointers to all the standard exception
classes (initialized during python startup - they're really
created in pure Python).
To raise one from C, you do something like:
PyErr_SetString(PyExc_IndexError, "index out of range");
Creating your own exception classes from C will take more
work. As usual with the C API, how much work depends on
how clever you are <wink>.
More information about the Python-list