diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2021-02-11 19:45:33 -0600 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2021-02-11 22:16:41 -0600 |
commit | 2581703a9c325146f88a4c9588918aea00e84640 (patch) | |
tree | 04d69cfbefa9a591ebb3aeabdd7d0550a73ea859 | |
parent | d06606c3fc03b7bd1f80abb47d96dae4ccbd8c97 (diff) | |
download | numpy-2581703a9c325146f88a4c9588918aea00e84640.tar.gz |
BUG: string->datetime64 does not support byte swapping
-rw-r--r-- | numpy/core/src/multiarray/datetime.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/numpy/core/src/multiarray/datetime.c b/numpy/core/src/multiarray/datetime.c index f817e1957..fdf4c0839 100644 --- a/numpy/core/src/multiarray/datetime.c +++ b/numpy/core/src/multiarray/datetime.c @@ -3993,23 +3993,24 @@ string_to_datetime_cast_resolve_descriptors( PyArray_Descr *given_descrs[2], PyArray_Descr *loop_descrs[2]) { - /* We currently support byte-swapping, so any (unicode) string is OK */ - Py_INCREF(given_descrs[0]); - loop_descrs[0] = given_descrs[0]; - if (given_descrs[1] == NULL) { /* NOTE: This doesn't actually work, and will error during the cast */ loop_descrs[1] = dtypes[1]->default_descr(dtypes[1]); if (loop_descrs[1] == NULL) { - Py_DECREF(loop_descrs[0]); return -1; } } else { - Py_INCREF(given_descrs[1]); - loop_descrs[1] = given_descrs[1]; + loop_descrs[1] = ensure_dtype_nbo(given_descrs[1]); + if (loop_descrs[1] == NULL) { + return -1; + } } + /* We currently support byte-swapping, so any (unicode) string is OK */ + Py_INCREF(given_descrs[0]); + loop_descrs[0] = given_descrs[0]; + return NPY_UNSAFE_CASTING; } |