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
Kirill Smelkov
cython
Commits
50f00cf8
Commit
50f00cf8
authored
Jun 06, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests that exception propagation works with the "@returns()" decorator.
parent
95bad952
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
tests/run/pure_py.py
tests/run/pure_py.py
+29
-0
No files found.
tests/run/pure_py.py
View file @
50f00cf8
...
...
@@ -217,6 +217,8 @@ def test_declare_c_types(n):
@
cython
.
ccall
@
cython
.
returns
(
cython
.
double
)
def
c_call
(
x
):
if
x
==
-
2.0
:
raise
RuntimeError
(
"huhu!"
)
return
x
...
...
@@ -235,6 +237,10 @@ def call_ccall(x):
1.0
>>> (is_compiled and 1) or result
1
>>> call_ccall(-2)
Traceback (most recent call last):
RuntimeError: huhu!
"""
ret
=
c_call
(
x
)
return
ret
,
cython
.
typeof
(
ret
)
...
...
@@ -244,6 +250,8 @@ def call_ccall(x):
@
cython
.
inline
@
cython
.
returns
(
cython
.
double
)
def
cdef_inline
(
x
):
if
x
==
-
2.0
:
raise
RuntimeError
(
"huhu!"
)
return
x
+
1
...
...
@@ -258,6 +266,10 @@ def call_cdef_inline(x):
'int'
>>> result == 2.0 or result
True
>>> call_cdef_inline(-2)
Traceback (most recent call last):
RuntimeError: huhu!
"""
ret
=
cdef_inline
(
x
)
return
ret
,
cython
.
typeof
(
ret
)
...
...
@@ -392,6 +404,23 @@ def ccall_except_check_always(x):
return
x
+
1
@
cython
.
test_fail_if_path_exists
(
"//CFuncDeclaratorNode//IntNode[@value = '-1']"
)
@
cython
.
test_assert_path_exists
(
"//CFuncDeclaratorNode"
)
@
cython
.
ccall
@
cython
.
returns
(
cython
.
long
)
@
cython
.
exceptval
(
check
=
False
)
def
ccall_except_no_check
(
x
):
"""
>>> ccall_except_no_check(41)
42
>>> try: _ = ccall_except_no_check(0) # no exception propagated!
... except ValueError: assert not is_compiled
"""
if
x
==
0
:
raise
ValueError
return
x
+
1
@
cython
.
final
@
cython
.
cclass
class
CClass
(
object
):
...
...
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