Some C-API functions clear the error indicator?
gagsl-py2 at yahoo.com.ar
Fri Jan 29 21:04:49 CET 2010
En Fri, 29 Jan 2010 11:37:09 -0300, Austin Bingham
<austin.bingham at gmail.com> escribió:
> I've noticed that several (many?) python functions seem to clear the
> error/exception indicators when they're called from a C/C++ program.
> For example, both PyImport_ImportModule and traceback.extract_tb()
> (called via the function call methods) do this: if error indicators
> are set prior to their call (as indicated by PyErr_Fetch, and
> including a call to PyErr_Restore), I see that they are unset (using
> the same method) after the call. This happens even when the functions
It's simple: you have to check *every* function call for failure. Many
functions return new object references and you have to properly decrement
them in case of failure, so in most cases this means that you have to
check each and every call.
More information about the Python-list