mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
gh-110850: Fix _PyTime_FromSecondsDouble() API (#116606)
Return 0 on success. Set an exception and return -1 on error. Fix os.timerfd_settime(): properly report exceptions on _PyTime_FromSecondsDouble() failure. No longer export _PyTime_FromSecondsDouble().
This commit is contained in:
parent
2731913dd5
commit
113053a070
4 changed files with 40 additions and 31 deletions
|
@ -565,6 +565,7 @@ pytime_from_double(PyTime_t *tp, double value, _PyTime_round_t round,
|
|||
/* See comments in pytime_double_to_denominator */
|
||||
if (!((double)PyTime_MIN <= d && d < -(double)PyTime_MIN)) {
|
||||
pytime_time_t_overflow();
|
||||
*tp = 0;
|
||||
return -1;
|
||||
}
|
||||
PyTime_t ns = (PyTime_t)d;
|
||||
|
@ -652,14 +653,10 @@ _PyTime_AsLong(PyTime_t ns)
|
|||
return PyLong_FromLongLong((long long)ns);
|
||||
}
|
||||
|
||||
PyTime_t
|
||||
_PyTime_FromSecondsDouble(double seconds, _PyTime_round_t round)
|
||||
int
|
||||
_PyTime_FromSecondsDouble(double seconds, _PyTime_round_t round, PyTime_t *result)
|
||||
{
|
||||
PyTime_t tp;
|
||||
if(pytime_from_double(&tp, seconds, round, SEC_TO_NS) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return tp;
|
||||
return pytime_from_double(result, seconds, round, SEC_TO_NS);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue