Skip to content

bpo-41710: Add _PyTime_AsTimespec_clamp() #28629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2021
Merged

bpo-41710: Add _PyTime_AsTimespec_clamp() #28629

merged 1 commit into from
Sep 30, 2021

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