scipy/scipy — pull request #4052 by WarrenWeckesser (2014-10-06 17:29:58+00:00)
Title: ENH (WIP): integrate: odeint: Handle exceptions in the callback functions.

Basic idea: There are C functions that are called by the Fortran solver
LSODA. These C functions call the user's Python callback function (i.e. the
definitions of the differential equations and Jacobian). If an error occurs
in the Python code, the C functions set the "number of equations" parameter
to -1 to indicate that an error has occurred. The Fortran code will now
check for this value, and simply return if it is detected. The error set
in the user's python code will propagate up to the Python code that called
LSODA, so the user gets the exception.

Change summary:
__odepack.h:
In the callback functions, instead of calling PyErr_Print() when an
error occurs, set *n = -1.
multipack.h:
Don't use PYERR2 (which does PyErr_Print and then sets a new exception).
Instead, just let the error propagate.
Fortran code:
Check for neq(1) being -1 on return from calls to user's code.