Commit 8d487689 authored by Christoph Groth's avatar Christoph Groth
Browse files

get rid of warning about implicit conversion to integer

parent 7c1e376c
......@@ -59,7 +59,22 @@ inline double number_from_pyobject(PyObject *obj)
template <>
inline long number_from_pyobject(PyObject *obj)
return PyInt_AsLong(obj);
// Before, we solely used PyInt_AsLong, but with Python 3.8 this started to
// trigger warnings of implicit truncation
// (
// However, truncation is exactly the desired behavior when explicitly
// creating a dtype=int array from floats. To solve the problem, we now
// explicitly convert to a Python integer before converting to C long.
obj = PyNumber_Long(obj);
obj = PyNumber_Int(obj);
if (!obj) return -1;
long ret = PyInt_AsLong(obj);
return ret;
template <>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment