bpo-20177: Migrate datetime.date.fromtimestamp to Argument Clinic by timhoffm · Pull Request #8535 · python/cpython (original) (raw)

You mean, I should have just one function not the two? I don't think this works for the following reason.

I have to use datetime.date.fromtimestamp for the clinic. If I just use date.fromtimestampit will complain (Parent class or module does not exist).
With the clinic declaration, this results in exactly the signature

datetime_date_fromtimestamp(PyTypeObject *type, PyObject *timestamp)

However, I cannot use this function in the PyDateTime_CAPI declaration (l.6075). If I try that, the compiler complains

/home/tim/dev/cpython/Modules/_datetimemodule.c:6075:5: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     datetime_date_fromtimestamp,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tim/dev/cpython/Modules/_datetimemodule.c:6075:5: note: (near initialization for ‘CAPI.Date_FromTimestamp’)

The function there is expected to have PyObject * as type, not PyTypeObject *. I don't know if that can be corrected, but reckon that it would be a breaking change to the CAPI which we do not want.