summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorTyler Reddy <tyler.je.reddy@gmail.com>2019-04-29 10:37:40 -0700
committerTyler Reddy <tyler.je.reddy@gmail.com>2019-04-30 14:52:25 -0700
commita85ceabe6ade23bf4502ae3dd57eff89beedbfd8 (patch)
treef2a2311bbca79a309e3f7383d59380aab4c53109 /numpy/core/src
parent9d157f3d931bed594dcf817a8bfff94bcbd1a592 (diff)
downloadnumpy-a85ceabe6ade23bf4502ae3dd57eff89beedbfd8.tar.gz
MAINT: reviewer adjustments in PR 10723
* add unit test for gh-9968, which currently fails on master * npy_longdouble.h include was missing in arraytypes.c.src, causing all sorts of unstable behavior for calls to npy_longdouble_from_PyLong() * correct control flow for PyBool_Type in string_to_long_double() function; include a unit test for np.longdouble(bool)
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/common/npy_longdouble.c3
-rw-r--r--numpy/core/src/multiarray/arraytypes.c.src5
2 files changed, 3 insertions, 5 deletions
diff --git a/numpy/core/src/common/npy_longdouble.c b/numpy/core/src/common/npy_longdouble.c
index 4e7541f8f..88c8616fd 100644
--- a/numpy/core/src/common/npy_longdouble.c
+++ b/numpy/core/src/common/npy_longdouble.c
@@ -172,8 +172,5 @@ npy_longdouble_from_PyLong(PyObject *long_obj) {
return -1;
}
- // Without this line, MSVC produces garbage (optimizes out result!?)
- printf("Double form is %f\n", (double) result);
-
return result;
}
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src
index d891f925a..afa44a627 100644
--- a/numpy/core/src/multiarray/arraytypes.c.src
+++ b/numpy/core/src/multiarray/arraytypes.c.src
@@ -30,6 +30,7 @@
#include <emmintrin.h>
#endif
+#include "npy_longdouble.h"
#include "numpyos.h"
#include <string.h>
@@ -331,9 +332,9 @@ string_to_long_double(PyObject*op)
/* Convert python long objects to a longdouble, without precision or range
* loss via a double.
*/
- if (PyLong_Check(op)
+ if ((PyLong_Check(op) && !PyBool_Check(op))
#if !defined(NPY_PY3K)
- || PyInt_Check(op)
+ || (PyInt_Check(op) && !PyBool_Check(op))
#endif
) {
return npy_longdouble_from_PyLong(op);