Re: Exception stomping
Stefan Behnel <[email protected]> Wed, 26 Nov 2008 09:27:19 +0100
| Newsgroups | gmane.comp.python.pyrex |
|---|---|
| Message-ID | <[email protected]> |
Stefan Behnel wrote: > Eric Huss wrote: >> I've run into a problem with how Pyrex handles the "current" exception >> (not sure if this has been discussed before). I know that the "reraise" >> issue has been fixed, but this is a slightly different issue where Pyrex >> does not make a backup of the "current" exception. >> >> If you call a Pyrex function that internally raises and catches an >> exception, but does not re-raise it, it leaves that exception set within >> the tstate object. This causes the exception to bleed out in unexpected >> ways. > > Please take a look at the way Cython 0.10.1 handles this. It stores the > current exception away when it enters a try block and restores it when an > exception has been caught in an except block and successfully handled (i.e. > the except block has exited normally). Here are the relevant test cases: http://hg.cython.org/cython-devel/file/tip/tests/run/funcexcept.pyx http://hg.cython.org/cython-devel/file/tip/tests/run/funcexceptchained.pyx http://hg.cython.org/cython-devel/file/tip/tests/run/funcexceptcypy.pyx http://hg.cython.org/cython-devel/file/tip/tests/run/funcexceptreturn.pyx http://hg.cython.org/cython-devel/file/tip/tests/run/exceptionrefcount.pyx Stefan