Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
serhiy-storchaka and vstinner authored Oct 3, 2025
commit 68433af3a29b75d6ecef5c1cf1ce838fe6250f14
6 changes: 4 additions & 2 deletions Python/pytime.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,18 +442,20 @@ checked_divmod(PyObject *a, PyObject *b)
static PyObject *
divide_and_round(PyObject *numerator, PyObject *denominator, _PyTime_round_t round)
{
PyObject *divmod, *result;
if (round == _PyTime_ROUND_UP) {
int isneg = PyObject_RichCompareBool(numerator, _PyLong_GetZero(), Py_LT);
if (isneg < 0) {
return NULL;
}
round = isneg ? _PyTime_ROUND_FLOOR : _PyTime_ROUND_CEILING;
}

if (round == _PyTime_ROUND_FLOOR) {
return PyNumber_FloorDivide(numerator, denominator);
}
else if (round == _PyTime_ROUND_CEILING) {

PyObject *divmod, *result;
if (round == _PyTime_ROUND_CEILING) {
divmod = checked_divmod(numerator, denominator);
if (divmod == NULL) {
return NULL;
Expand Down