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
c0da2af7
Commit
c0da2af7
authored
Jul 02, 2015
by
Ian Henriksen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Break C++ exception translating code into a separate function.
parent
1ea0816e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
18 deletions
+21
-18
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+21
-18
No files found.
Cython/Compiler/ExprNodes.py
View file @
c0da2af7
...
@@ -179,6 +179,25 @@ def infer_sequence_item_type(env, seq_node, index_node=None, seq_type=None):
...
@@ -179,6 +179,25 @@ def infer_sequence_item_type(env, seq_node, index_node=None, seq_type=None):
return
item_types
.
pop
()
return
item_types
.
pop
()
return
None
return
None
def
translate_cpp_exception
(
code
,
pos
,
inside
,
exception_value
,
nogil
):
if
exception_value
is
None
:
raise_py_exception
=
"__Pyx_CppExn2PyErr();"
elif
exception_value
.
type
.
is_pyobject
:
raise_py_exception
=
'try { throw; } catch(const std::exception& exn) { PyErr_SetString(%s, exn.what()); } catch(...) { PyErr_SetNone(%s); }'
%
(
exception_value
.
entry
.
cname
,
exception_value
.
entry
.
cname
)
else
:
raise_py_exception
=
'%s(); if (!PyErr_Occurred()) PyErr_SetString(PyExc_RuntimeError , "Error converting c++ exception.");'
%
exception_value
.
entry
.
cname
code
.
putln
(
"try {"
)
code
.
putln
(
"%s;"
%
inside
)
code
.
putln
(
"} catch(...) {"
)
if
nogil
:
code
.
put_ensure_gil
(
declare_gilstate
=
True
)
code
.
putln
(
raise_py_exception
)
if
nogil
:
code
.
put_release_ensured_gil
()
code
.
putln
(
code
.
error_goto
(
pos
))
code
.
putln
(
"}"
)
class
ExprNode
(
Node
):
class
ExprNode
(
Node
):
# subexprs [string] Class var holding names of subexpr node attrs
# subexprs [string] Class var holding names of subexpr node attrs
...
@@ -5132,24 +5151,8 @@ class SimpleCallNode(CallNode):
...
@@ -5132,24 +5151,8 @@ class SimpleCallNode(CallNode):
else
:
else
:
lhs
=
""
lhs
=
""
if
func_type
.
exception_check
==
'+'
:
if
func_type
.
exception_check
==
'+'
:
if
func_type
.
exception_value
is
None
:
translate_cpp_exception
(
code
,
self
.
pos
,
'%s%s;'
%
(
lhs
,
rhs
),
raise_py_exception
=
"__Pyx_CppExn2PyErr();"
func_type
.
exception_value
,
self
.
nogil
)
elif
func_type
.
exception_value
.
type
.
is_pyobject
:
raise_py_exception
=
'try { throw; } catch(const std::exception& exn) { PyErr_SetString(%s, exn.what()); } catch(...) { PyErr_SetNone(%s); }'
%
(
func_type
.
exception_value
.
entry
.
cname
,
func_type
.
exception_value
.
entry
.
cname
)
else
:
raise_py_exception
=
'%s(); if (!PyErr_Occurred()) PyErr_SetString(PyExc_RuntimeError , "Error converting c++ exception.");'
%
func_type
.
exception_value
.
entry
.
cname
code
.
putln
(
"try {"
)
code
.
putln
(
"%s%s;"
%
(
lhs
,
rhs
))
code
.
putln
(
"} catch(...) {"
)
if
self
.
nogil
:
code
.
put_ensure_gil
(
declare_gilstate
=
True
)
code
.
putln
(
raise_py_exception
)
if
self
.
nogil
:
code
.
put_release_ensured_gil
()
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"}"
)
else
:
else
:
if
exc_checks
:
if
exc_checks
:
goto_error
=
code
.
error_goto_if
(
" && "
.
join
(
exc_checks
),
self
.
pos
)
goto_error
=
code
.
error_goto_if
(
" && "
.
join
(
exc_checks
),
self
.
pos
)
...
...
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