summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-03-11 16:35:29 (GMT)
committerGitHub <noreply@github.com>2024-03-11 16:35:29 (GMT)
commit113053a070ba753101f73553ef6435c5c6c9f3f7 (patch)
tree9f97e4dc49ceafd5a464f169d142225e170ab7be /Python
parent2731913dd5234ff5ab630a3b7f1c98ad79d4d9df (diff)
downloadcpython-113053a070ba753101f73553ef6435c5c6c9f3f7.zip
cpython-113053a070ba753101f73553ef6435c5c6c9f3f7.tar.gz
cpython-113053a070ba753101f73553ef6435c5c6c9f3f7.tar.bz2
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().
Diffstat (limited to 'Python')
-rw-r--r--Python/pytime.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/Python/pytime.c b/Python/pytime.c
index 90ef2ee..70d92ca 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -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);
}