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
81fc3458
Commit
81fc3458
authored
Apr 03, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make sure we safely propagate CPython's own conversion exceptions through __PYX_VERIFY_RETURN_INT()
parent
6d2ca1c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
Cython/Utility/TypeConversion.c
Cython/Utility/TypeConversion.c
+12
-4
No files found.
Cython/Utility/TypeConversion.c
View file @
81fc3458
...
...
@@ -545,11 +545,19 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value) {
// see CIntFromPy
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value) \
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value) \
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc) \
{ \
func_type value = func_value; \
if (sizeof(target_type) < sizeof(func_type)) { \
if (unlikely(value != (func_type) (target_type) value)) { \
func_type zero = 0; \
if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred())) \
return (target_type) -1; \
if (is_unsigned && unlikely(value < zero)) \
goto raise_neg_overflow; \
else \
...
...
@@ -628,9 +636,9 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) {
}
#endif
if
(
sizeof
({{
TYPE
}})
<=
sizeof
(
unsigned
long
))
{
__PYX_VERIFY_RETURN_INT
({{
TYPE
}},
unsigned
long
,
PyLong_AsUnsignedLong
(
x
))
__PYX_VERIFY_RETURN_INT
_EXC
({{
TYPE
}},
unsigned
long
,
PyLong_AsUnsignedLong
(
x
))
}
else
if
(
sizeof
({{
TYPE
}})
<=
sizeof
(
unsigned
PY_LONG_LONG
))
{
__PYX_VERIFY_RETURN_INT
({{
TYPE
}},
unsigned
PY_LONG_LONG
,
PyLong_AsUnsignedLongLong
(
x
))
__PYX_VERIFY_RETURN_INT
_EXC
({{
TYPE
}},
unsigned
PY_LONG_LONG
,
PyLong_AsUnsignedLongLong
(
x
))
}
}
else
{
// signed
...
...
@@ -656,9 +664,9 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) {
}
#endif
if
(
sizeof
({{
TYPE
}})
<=
sizeof
(
long
))
{
__PYX_VERIFY_RETURN_INT
({{
TYPE
}},
long
,
PyLong_AsLong
(
x
))
__PYX_VERIFY_RETURN_INT
_EXC
({{
TYPE
}},
long
,
PyLong_AsLong
(
x
))
}
else
if
(
sizeof
({{
TYPE
}})
<=
sizeof
(
PY_LONG_LONG
))
{
__PYX_VERIFY_RETURN_INT
({{
TYPE
}},
PY_LONG_LONG
,
PyLong_AsLongLong
(
x
))
__PYX_VERIFY_RETURN_INT
_EXC
({{
TYPE
}},
PY_LONG_LONG
,
PyLong_AsLongLong
(
x
))
}
}
{
...
...
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