[Pyrex] Pyrex exception reraise behavior

Miles semanticist at gmail.com
Sun Jul 13 09:57:21 CEST 2008


Hi all,

It looks to me like Pyrex's behavior for reraising exceptions differs
somewhat from Python's:

# pyrex_raise.pyx and python_raise.py:
def my_raise():
    try:
        raise NotImplementedError
    except:
        raise

>>> import pyrex_raise, python_raise, sys, traceback
>>> python_raise.my_raise()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "python_raise.py", line 3, in my_raise
    raise NotImplementedError
NotImplementedError
>>> sys.exc_info()
(None, None, None)
>>>
>>> pyrex_raise.crash()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyrex_raise.pyx", line 5, in pyrex_raise.my_raise
    raise
  File "pyrex_raise.pyx", line 3, in pyrex_raise.my_raise
    raise NotImplementedError
NotImplementedError
>>> sys.exc_info()
(<type 'exceptions.NotImplementedError'>, NotImplementedError(),
<traceback object at 0x7bda0>)
>>> traceback.print_tb(sys.exc_info()[2])
  File "pyrex_raise.pyx", line 3, in pyrex_raise.my_raise
    raise NotImplementedError

It looks like there's Pyrex code written specifically to handle
reraising exceptions, but it's not getting generated here, so I was
wondering if this behavior was intentional or a bug.

Thanks,
Miles



More information about the Pyrex mailing list