Message297344
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(). |
|
Date |
User |
Action |
Args |
2017-06-30 07:45:13 | vstinner | set | recipients:
+ vstinner, pitrou |
2017-06-30 07:45:13 | vstinner | link | issue30807 messages |
2017-06-30 07:45:12 | vstinner | create | |
|