Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Sep 29, 2021

Add the _PyTime_AsTimespec_clamp() function: similar to
_PyTime_AsTimespec(), but clamp to _PyTime_t min/max and don't raise
an exception.

PyThread_acquire_lock_timed() now uses _PyTime_AsTimespec_clamp() to
remove the Py_UNREACHABLE() code path.

  • Add _PyTime_AsTime_t() function.
  • Add PY_TIME_T_MIN and PY_TIME_T_MAX constants.
  • Replace _PyTime_AsTimeval_noraise() with _PyTime_AsTimeval_clamp().
  • Add pytime_divide_round_up().
  • Fix integer overflow in pytime_divide().
  • Add pytime_divmod() function.

https://bugs.python.org/issue41710

@vstinner vstinner changed the title bpo-41710: Add _PyTime_AsTimespec_truncate() bpo-41710: Add _PyTime_AsTimespec_clamp() Sep 29, 2021
Add the _PyTime_AsTimespec_clamp() function: similar to
_PyTime_AsTimespec(), but clamp to _PyTime_t min/max and don't raise
an exception.

PyThread_acquire_lock_timed() now uses _PyTime_AsTimespec_clamp() to
remove the Py_UNREACHABLE() code path.

* Add _PyTime_AsTime_t() function.
* Add PY_TIME_T_MIN and PY_TIME_T_MAX constants.
* Replace _PyTime_AsTimeval_noraise() with _PyTime_AsTimeval_clamp().
* Add pytime_divide_round_up() function.
* Fix integer overflow in pytime_divide().
* Add pytime_divmod() function.
@vstinner vstinner merged commit 09796f2 into python:main Sep 30, 2021
@vstinner vstinner deleted the time_t branch September 30, 2021 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants