Commit ee5ac4a5 authored by Stefan Behnel's avatar Stefan Behnel

add failing Py3 exception test

parent a3cf886d
...@@ -12,6 +12,7 @@ for_from_pyvar_loop_T601 ...@@ -12,6 +12,7 @@ for_from_pyvar_loop_T601
temp_sideeffects_T654 # not really a bug, Cython warns about it temp_sideeffects_T654 # not really a bug, Cython warns about it
slice2_T636 slice2_T636
inherited_final_method inherited_final_method
tryfinallychaining # also see FIXME in "yield_from_pep380" test
# CPython regression tests that don't current work: # CPython regression tests that don't current work:
pyregr.test_signal pyregr.test_signal
......
# mode: run
# tag: exceptions, tryfinally
import sys
IS_PY3 = sys.version_info[0] >= 3
def test_finally_c():
"""
>>> def test_finally_py():
... try:
... raise AttributeError()
... finally:
... raise KeyError()
>>> try:
... test_finally_py()
... except KeyError:
... print(sys.exc_info()[0] is KeyError or sys.exc_info()[0])
... if IS_PY3:
... print(isinstance(sys.exc_info()[1].__context__, AttributeError)
... or sys.exc_info()[1].__context__)
... else:
... print(True)
True
True
>>> try:
... test_finally_c()
... except KeyError:
... print(sys.exc_info()[0] is KeyError or sys.exc_info()[0])
... if IS_PY3:
... print(isinstance(sys.exc_info()[1].__context__, AttributeError)
... or sys.exc_info()[1].__context__)
... else:
... print(True)
True
True
"""
try:
raise AttributeError()
finally:
raise KeyError()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment