summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2019-07-28 14:14:55 -0700
committerEric Wieser <wieser.eric@gmail.com>2019-07-28 14:14:55 -0700
commit621e41d584ee4ec9232576cc637bcc48cf3892be (patch)
tree2cba86cac6f2dfbe1bbdbd85edf2d92d732a3084
parent84e841281361bc708ad9b413433ebb2524d710af (diff)
downloadnumpy-621e41d584ee4ec9232576cc637bcc48cf3892be.tar.gz
BUG: Fix DeprecationWarning in python 3.8 due to implicit conversion to int
Since `total_seconds` returns a python `float`, its easiest to convert to a C float and do the int conversion there Fixes gh-14077
-rw-r--r--numpy/core/src/multiarray/datetime.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/datetime.c b/numpy/core/src/multiarray/datetime.c
index 768eb1e64..60e6bbae2 100644
--- a/numpy/core/src/multiarray/datetime.c
+++ b/numpy/core/src/multiarray/datetime.c
@@ -2272,7 +2272,10 @@ convert_pydatetime_to_datetimestruct(PyObject *obj, npy_datetimestruct *out,
if (tmp == NULL) {
return -1;
}
- seconds_offset = PyInt_AsLong(tmp);
+ /* Rounding here is no worse than the integer division below.
+ * Only whole minute offsets are supported by numpy anyway.
+ */
+ seconds_offset = (int)PyFloat_AsDouble(tmp);
if (error_converting(seconds_offset)) {
Py_DECREF(tmp);
return -1;