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
4446b3a4
Commit
4446b3a4
authored
Jul 10, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
another PyPy fix for double conversion: PyNumber_Float() to properly convert strings etc.
parent
8e92f1c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+10
-8
No files found.
Cython/Utility/Optimize.c
View file @
4446b3a4
...
...
@@ -442,24 +442,26 @@ static CYTHON_INLINE int __Pyx_init_unicode_iteration(
/////////////// pyobject_as_double.proto ///////////////
#if CYTHON_COMPILING_IN_PYPY
// currently works because PyPy calls float() internally
#define __Pyx_PyObject_AsDouble(obj) PyFloat_AsDouble(obj)
#else
static
double
__Pyx__PyObject_AsDouble
(
PyObject
*
obj
);
/* proto */
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyObject_AsDouble(obj) \
(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) : \
likely(PyInt_CheckExact(obj)) ? \
PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
#else
#define __Pyx_PyObject_AsDouble(obj) \
((likely(PyFloat_CheckExact(obj))) ? \
PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
#endif
/////////////// pyobject_as_double ///////////////
#if !CYTHON_COMPILING_IN_PYPY
static
double
__Pyx__PyObject_AsDouble
(
PyObject
*
obj
)
{
PyObject
*
float_value
;
#if CYTHON_COMPILING_IN_PYPY
float_value
=
PyNumber_Float
(
obj
);
#else
if
(
Py_TYPE
(
obj
)
->
tp_as_number
&&
Py_TYPE
(
obj
)
->
tp_as_number
->
nb_float
)
{
return
PyFloat_AsDouble
(
obj
);
}
else
if
(
PyUnicode_CheckExact
(
obj
)
||
PyBytes_CheckExact
(
obj
))
{
...
...
@@ -476,6 +478,7 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) {
PyTuple_SET_ITEM
(
args
,
0
,
0
);
Py_DECREF
(
args
);
}
#endif
if
(
likely
(
float_value
))
{
double
value
=
PyFloat_AS_DOUBLE
(
float_value
);
Py_DECREF
(
float_value
);
...
...
@@ -484,4 +487,3 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) {
bad:
return
(
double
)
-
1
;
}
#endif
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