Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: remove total_seconds compat from json #17341

Merged
merged 1 commit into from Aug 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 7 additions & 10 deletions pandas/_libs/src/ujson/python/objToJSON.c
Expand Up @@ -329,7 +329,7 @@ static Py_ssize_t get_attr_length(PyObject *obj, char *attr) {
return ret;
}

npy_int64 get_long_attr(PyObject *o, const char *attr) {
static npy_int64 get_long_attr(PyObject *o, const char *attr) {
npy_int64 long_val;
PyObject *value = PyObject_GetAttrString(o, attr);
long_val = (PyLong_Check(value) ?
Expand All @@ -338,15 +338,12 @@ npy_int64 get_long_attr(PyObject *o, const char *attr) {
return long_val;
}

npy_float64 total_seconds(PyObject *td) {
// Python 2.6 compat
// TODO(anyone): remove this legacy workaround with a more
// direct td.total_seconds()
npy_int64 microseconds = get_long_attr(td, "microseconds");
npy_int64 seconds = get_long_attr(td, "seconds");
npy_int64 days = get_long_attr(td, "days");
npy_int64 days_in_seconds = days * 24LL * 3600LL;
return (microseconds + (seconds + days_in_seconds) * 1000000.0) / 1000000.0;
static npy_float64 total_seconds(PyObject *td) {
npy_float64 double_val;
PyObject *value = PyObject_CallMethod(td, "total_seconds", NULL);
double_val = PyFloat_AS_DOUBLE(value);
Py_DECREF(value);
return double_val;
}

static PyObject *get_item(PyObject *obj, Py_ssize_t i) {
Expand Down