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
a19b8a99
Commit
a19b8a99
authored
Sep 17, 2018
by
Matt Wozniski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test an "except +" function returning <object>NULL
This provides a test case for #2603
parent
a47d63eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
tests/run/cpp_exceptions.pyx
tests/run/cpp_exceptions.pyx
+15
-0
tests/run/cpp_exceptions_helper.h
tests/run/cpp_exceptions_helper.h
+9
-0
No files found.
tests/run/cpp_exceptions.pyx
View file @
a19b8a99
...
...
@@ -21,6 +21,8 @@ cdef extern from "cpp_exceptions_helper.h":
cdef
void
raise_typeerror
()
except
+
cdef
void
raise_underflow
()
except
+
cdef
raise_or_throw
(
bint
py
)
except
+
cdef
cppclass
Foo
:
int
bar_raw
"bar"
(
bint
fire
)
except
+
int
bar_value
"bar"
(
bint
fire
)
except
+
ValueError
...
...
@@ -98,6 +100,19 @@ def test_underflow():
"""
raise_underflow
()
def
test_func_that_can_raise_or_throw
(
bint
py
):
"""
>>> test_func_that_can_raise_or_throw(0)
Traceback (most recent call last):
...
RuntimeError: oopsie
>>> test_func_that_can_raise_or_throw(1)
Traceback (most recent call last):
...
ValueError: oopsie
"""
raise_or_throw
(
py
)
def
test_int_raw
(
bint
fire
):
"""
>>> test_int_raw(False)
...
...
tests/run/cpp_exceptions_helper.h
View file @
a19b8a99
#include <Python.h>
#include <ios>
#include <new>
#include <stdexcept>
...
...
@@ -61,3 +62,11 @@ void raise_typeerror() {
void
raise_underflow
()
{
throw
std
::
underflow_error
(
"underflow_error"
);
}
PyObject
*
raise_or_throw
(
int
py
)
{
if
(
!
py
)
{
throw
std
::
runtime_error
(
"oopsie"
);
}
PyErr_SetString
(
PyExc_ValueError
,
"oopsie"
);
return
NULL
;
}
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