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
3716a375
Commit
3716a375
authored
Jan 15, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Argument parsing error handling
parent
859e52bb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-14
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+14
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
3716a375
...
@@ -3588,20 +3588,7 @@ class CoerceFromPyTypeNode(CoercionNode):
...
@@ -3588,20 +3588,7 @@ class CoerceFromPyTypeNode(CoercionNode):
code
.
putln
(
'%s = %s; %s'
%
(
code
.
putln
(
'%s = %s; %s'
%
(
self
.
result_code
,
self
.
result_code
,
rhs
,
rhs
,
code
.
error_goto_if
(
self
.
error_cond
(),
self
.
pos
)))
code
.
error_goto_if
(
self
.
type
.
error_condition
(
self
.
result_code
),
self
.
pos
)))
def
error_cond
(
self
):
conds
=
[]
if
self
.
type
.
is_string
:
conds
.
append
(
"(!%s)"
%
self
.
result_code
)
elif
self
.
type
.
exception_value
is
not
None
:
conds
.
append
(
"(%s == %s)"
%
(
self
.
result_code
,
self
.
type
.
exception_value
))
if
self
.
type
.
exception_check
:
conds
.
append
(
"PyErr_Occurred()"
)
if
len
(
conds
)
>
0
:
return
" && "
.
join
(
conds
)
else
:
return
0
class
CoerceToBooleanNode
(
CoercionNode
):
class
CoerceToBooleanNode
(
CoercionNode
):
...
...
Cython/Compiler/Nodes.py
View file @
3716a375
...
@@ -1311,12 +1311,13 @@ class DefNode(FuncDefNode):
...
@@ -1311,12 +1311,13 @@ class DefNode(FuncDefNode):
def
generate_arg_conversion_from_pyobject
(
self
,
arg
,
code
):
def
generate_arg_conversion_from_pyobject
(
self
,
arg
,
code
):
new_type
=
arg
.
type
new_type
=
arg
.
type
func
=
new_type
.
from_py_function
func
=
new_type
.
from_py_function
# copied from CoerceFromPyTypeNode
if
func
:
if
func
:
code
.
putln
(
"%s = %s(%s); %s"
%
(
code
.
putln
(
"%s = %s(%s); %s"
%
(
arg
.
entry
.
cname
,
arg
.
entry
.
cname
,
func
,
func
,
arg
.
hdr_cname
,
arg
.
hdr_cname
,
code
.
error_goto_if
_PyErr
(
arg
.
pos
)))
code
.
error_goto_if
(
new_type
.
error_condition
(
arg
.
entry
.
cname
),
arg
.
pos
)))
else
:
else
:
error
(
arg
.
pos
,
error
(
arg
.
pos
,
"Cannot convert Python object argument to type '%s'"
"Cannot convert Python object argument to type '%s'"
...
...
Cython/Compiler/PyrexTypes.py
View file @
3716a375
...
@@ -302,6 +302,19 @@ class CType(PyrexType):
...
@@ -302,6 +302,19 @@ class CType(PyrexType):
from_py_function
=
None
from_py_function
=
None
exception_value
=
None
exception_value
=
None
exception_check
=
1
exception_check
=
1
def
error_condition
(
self
,
result_code
):
conds
=
[]
if
self
.
is_string
:
conds
.
append
(
"(!%s)"
%
result_code
)
elif
self
.
exception_value
is
not
None
:
conds
.
append
(
"(%s == (%s)%s)"
%
(
result_code
,
self
.
sign_and_name
(),
self
.
exception_value
))
if
self
.
exception_check
:
conds
.
append
(
"PyErr_Occurred()"
)
if
len
(
conds
)
>
0
:
return
" && "
.
join
(
conds
)
else
:
return
0
class
CVoidType
(
CType
):
class
CVoidType
(
CType
):
...
@@ -432,7 +445,7 @@ class CUIntType(CIntType):
...
@@ -432,7 +445,7 @@ class CUIntType(CIntType):
to_py_function
=
"PyLong_FromUnsignedLong"
to_py_function
=
"PyLong_FromUnsignedLong"
from_py_function
=
"PyInt_AsUnsignedLongMask"
from_py_function
=
"PyInt_AsUnsignedLongMask"
exception_value
=
None
exception_value
=
-
1
class
CULongType
(
CUIntType
):
class
CULongType
(
CUIntType
):
...
...
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