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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
3d1bd94a
Commit
3d1bd94a
authored
Sep 17, 2018
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'except_plus_null_pyobject' of
https://github.com/bloomberg/cython
parents
f61160ed
790b0994
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
22 deletions
+21
-22
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
tests/run/cpp_exceptions.pyx
tests/run/cpp_exceptions.pyx
+14
-15
tests/run/cpp_exceptions_helper.h
tests/run/cpp_exceptions_helper.h
+6
-6
No files found.
Cython/Compiler/ExprNodes.py
View file @
3d1bd94a
...
...
@@ -5846,7 +5846,7 @@ class SimpleCallNode(CallNode):
elif
self
.
type
.
is_memoryviewslice
:
assert
self
.
is_temp
exc_checks
.
append
(
self
.
type
.
error_condition
(
self
.
result
()))
el
se
:
el
if
func_type
.
exception_check
!=
'+'
:
exc_val
=
func_type
.
exception_value
exc_check
=
func_type
.
exception_check
if
exc_val
is
not
None
:
...
...
tests/run/cpp_exceptions.pyx
View file @
3d1bd94a
...
...
@@ -21,7 +21,7 @@ cdef extern from "cpp_exceptions_helper.h":
cdef
void
raise_typeerror
()
except
+
cdef
void
raise_underflow
()
except
+
cdef
object
raise_py
(
bint
fire_
py
)
except
+
cdef
raise_or_throw
(
bint
py
)
except
+
cdef
cppclass
Foo
:
int
bar_raw
"bar"
(
bint
fire
)
except
+
...
...
@@ -100,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)
...
...
@@ -201,17 +214,3 @@ def test_cppclass_method_custom(bint fire):
foo
.
bar_custom
(
fire
)
finally
:
del
foo
def
test_py
(
bint
py_fire
):
"""
>>> test_py(True)
Traceback (most recent call last):
...
RuntimeError: py error
>>> test_py(False)
Traceback (most recent call last):
...
IndexError: c++ error
"""
raise_py
(
py_fire
)
tests/run/cpp_exceptions_helper.h
View file @
3d1bd94a
#include <Python.h>
#include <ios>
#include <new>
#include <stdexcept>
...
...
@@ -62,11 +63,10 @@ void raise_underflow() {
throw
std
::
underflow_error
(
"underflow_error"
);
}
PyObject
*
raise_py
(
int
fire_py
)
{
if
(
fire_py
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"py error"
);
PyObject
*
raise_or_throw
(
int
py
)
{
if
(
!
py
)
{
throw
std
::
runtime_error
(
"oopsie"
);
}
PyErr_SetString
(
PyExc_ValueError
,
"oopsie"
);
return
NULL
;
}
else
{
throw
std
::
out_of_range
(
"c++ error"
);
}
}
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