Skip to content

gh-67795: Refactor pytime.c code handling double - #162904

Draft
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:pytime
Draft

vstinner wants to merge 1 commit into
python:mainfrom
vstinner:pytime

Conversation

@vstinner

@vstinner vstinner commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

_PyTime_FromSecondsDouble() now raises ValueError instead of OverflowError if the argument is not-a-number (NaN).

Changes:

  • Add pytime_double_to_time_t() and pytime_from_double_cast() helper functions.
  • Add tests on _PyTime_FromSecondsDouble().
  • Reuse pytime_mul_check_overflow() in _PyTime_FromSeconds().
  • Simplify _PyTime_Add() for positive numbers.
_PyTime_FromSecondsDouble() now raises ValueError instead of
OverflowError if the argument is not-a-number (NaN).

Changes:

* Add pytime_double_to_time_t() and pytime_from_double_cast() helper
  functions.
* Add tests on _PyTime_FromSecondsDouble().
* Reuse pytime_mul_check_overflow() in _PyTime_FromSeconds().
* Simplify _PyTime_Add() for positive numbers.
@vstinner

vstinner commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Hum. I will merge #162906 first: in fact, we no longer need _PyTime_FromSecondsDouble().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant