Author haypo
Recipients haypo, pitrou
Date 2017-06-30.07:45:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAMpsgwZWQcKHRA-KQg_RNN9F3zLx8nkQWEa0pWFvw-X+RqfLcg@mail.gmail.com>
In-reply-to <1498769601.39.0.0123944005462.issue30807@psf.upfronthosting.co.za>
Content
Antoine Pitrou added the comment:
> If I use the PyTime APIs, it will change the signature from
>   setitimer($module, which, seconds, interval=0.0, /)
> to
>   setitimer($module, which, seconds, interval=None, /).
>
> I'm not sure that's ok in a bugfix release?

I understand that you want to use _PyTime_FromSecondsObject(), which
is the right function to use. This function uses PyFloat_AsDouble() or
PyLong_AsLongLong().

The current code uses:

    if (!_PyArg_ParseStack(args, nargs, "id|d:setitimer",
        &which, &seconds, &interval)) {
        goto exit;
    }

The "d" format uses PyFloat_AsDouble(). This function uses
Py_TYPE(op)->tp_as_number->nb_float(op) to convert an object to a
float.

Hum, it seems like the main difference is that
_PyTime_FromSecondsObject() doesn't handle objects defining
__float__() the same way. For example, _PyTime_FromSecondsObject()
rounds a decimal.Decimal to an integer, not a float :-/ It looks like
a bug in _PyTime_FromSecondsObject() which should first try to call
PyFloat_AsDouble(), catch TypeError and fallback to
PyLong_AsLongLong().
History
Date User Action Args
2017-06-30 07:45:13hayposetrecipients: + haypo, pitrou
2017-06-30 07:45:13haypolinkissue30807 messages
2017-06-30 07:45:12haypocreate