Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
ecf22d5a
Commit
ecf22d5a
authored
Oct 18, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new test case for reraising exceptions
parent
cae4fe60
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
tests/run/funcexceptreraise.pyx
tests/run/funcexceptreraise.pyx
+56
-0
No files found.
tests/run/funcexceptreraise.pyx
0 → 100644
View file @
ecf22d5a
import
sys
def
reraise
(
f
,
exc
):
"""
>>> def f(exc): raise exc
>>> reraise(f, TypeError)
Traceback (most recent call last):
TypeError
>>> def f(exc): raise exc('hiho')
>>> reraise(f, TypeError)
Traceback (most recent call last):
TypeError: hiho
"""
try
:
f
(
exc
)
except
:
assert
sys
.
exc_info
()[
0
]
is
exc
,
str
(
sys
.
exc_info
()[
1
])
raise
def
reraise_original
(
f
,
exc
,
raise_catch
):
"""
>>> def f(exc): raise exc
>>> def raise_catch_py():
... try: raise ValueError
... except: pass
>>> reraise_original(f, TypeError, raise_catch_py)
Traceback (most recent call last):
TypeError
>>> reraise_original(f, TypeError, raise_catch_cy)
Traceback (most recent call last):
TypeError
>>> reraise_original(f, TypeError, raise_catch_cy_non_empty)
Traceback (most recent call last):
TypeError
"""
try
:
f
(
exc
)
except
:
raise_catch
()
assert
sys
.
exc_info
()[
0
]
is
exc
,
str
(
sys
.
exc_info
()[
1
])
raise
def
raise_catch_cy
():
try
:
raise
ValueError
except
:
pass
def
raise_catch_cy_non_empty
():
try
:
raise
ValueError
except
:
a
=
1
+
1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment