static-frame / arraykit

Python C Extensions for StaticFrame
Other
8 stars 2 forks source link

Need to decref to_numpy in `isna_element` #104

Closed flexatone closed 1 year ago

flexatone commented 1 year ago
    // Try to identify Pandas Timestamp NATs
    if (PyObject_HasAttrString(element, "to_numpy")) {
        PyObject *to_numpy = PyObject_GetAttrString(element, "to_numpy");
        if (!PyCallable_Check(to_numpy)) {
            Py_RETURN_FALSE;
        }
        PyObject* post = PyObject_CallFunction(to_numpy, NULL);
        if (post == NULL) return NULL;
        return PyBool_FromLong(PyArrayScalar_VAL(post, Datetime) == NPY_DATETIME_NAT);
    }