jeudi 6 février 2020

Why the PyObject is NULL after creation?

I have declared this function:

PyObject * A::func(const void *data) const {
    const time_t *time = reinterpret_cast<const time_t *>(data);
    std::tm *now = std::gmtime(time);
    PyObject *date_py = PyDate_FromDate(static_cast<int32_t>(now->tm_year + 1900), static_cast<int32_t>(now->tm_mon + 1),
                                        static_cast<int32_t>(now->tm_mday));
    PyObject_Print(date_py, stdout, 0);
    return date_py;
}

All the parameters that i use in PyDate_FromDate are int, but after calling this function and printing the date_py pyobject the result is null, like if I never created the object.

EDITED: data is a pointer to an int, in the test i'm running now->tm_year = 100, now->tm_mon = 6 and now->tm_mday = 2

What is the problem here?

Aucun commentaire:

Enregistrer un commentaire