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:
Victor Stinner 2024-03-11 17:35:29 +01:00 committed by GitHub
parent 2731913dd5
commit 113053a070
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 40 additions and 31 deletions

View file

@ -132,8 +132,10 @@ PyAPI_FUNC(int) _PyTime_ObjectToTimespec(
PyAPI_FUNC(PyTime_t) _PyTime_FromSeconds(int seconds);
// Create a timestamp from a number of seconds in double.
// Export for '_socket' shared extension.
PyAPI_FUNC(PyTime_t) _PyTime_FromSecondsDouble(double seconds, _PyTime_round_t round);
extern int _PyTime_FromSecondsDouble(
double seconds,
_PyTime_round_t round,
PyTime_t *result);
// Macro to create a timestamp from a number of seconds, no integer overflow.
// Only use the macro for small values, prefer _PyTime_FromSeconds().