bmcage/odes

Exception handling from #27 does not function as expected

aragilar opened this issue · 0 comments

Was digging to why I was getting errors like SystemError: x returned a result with an error set (x is a placeholder) from inside odes, it appears except -1/except? -1 doesn't behave like we expected (or at least how I expect it): it appears what it does is propagate the exception upwards when -1 is returned (rather than returning -1 on an exception). This means if you do raise an exception inside user code, you get weird SystemErrors which occur at the next "python" frame (which may be inside cython-compiled code). I think the solution is to remove the except tags and use try-except with Exception (or BaseException), and return the error code manually in the except statement. I guess we should ask about this on the one of the cython mailing lists?

@florian98765 Did you have an example of where the exception handling works? I currently have a short test which I'll provide as a PR which breaks for me, but if you have an working example it may help understand what's going on...