[Pyrex] Reraise not inside except clause
Stefan Behnel
stefan_ml at behnel.de
Tue Oct 16 08:28:22 CEST 2007
Robert Kern wrote:
> It is valid in Python to have an empty "raise" statement anywhere, and it used
> to be valid in Pyrex before 0.9.6. This new restriction breaks PyProtocol's
> _speedups.pyx. Here is a smaller example:
>
>
> [raiseerr]$ cat raiseerr.pyx
> def raise_err():
> if True:
> raise
>
> def exception():
> try:
> raise ValueError('foo')
> except:
> raise_err()
>
> exception()
> [raiseerr]$ python raiseerr.pyx
> Traceback (most recent call last):
> File "raiseerr.pyx", line 11, in <module>
> exception()
> File "raiseerr.pyx", line 9, in exception
> raise_err()
> File "raiseerr.pyx", line 7, in exception
> raise ValueError('foo')
> ValueError: foo
> [raiseerr]$ pyrexc raiseerr.pyx
> /Users/rkern/hg/raiseerr/raiseerr.pyx:3:8: Reraise not inside except clause
>
>
> Can this restriction be reverted?
lxml has been doing something similar for a while: catch an exception in a
callback and re-raise it when back in the normal execution context, but we
have stored the instantiated exception explicitly in the callback context and
raised it from there, which works perfectly. Something like that might work
here as well.
Stefan
More information about the Pyrex
mailing list