Skip to content

gh-110850: Replace private _PyTime_MAX with public PyTime_MAX #115751

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
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 1 addition & 5 deletions Include/internal/pycore_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,6 @@ extern int _PyTime_PerfCounterWithInfo(
PyTime_t *t,
_Py_clock_info_t *info);

// Alias for backward compatibility
#define _PyTime_MIN PyTime_MIN
#define _PyTime_MAX PyTime_MAX


// --- _PyDeadline -----------------------------------------------------------

Expand Down Expand Up @@ -352,7 +348,7 @@ extern int _PyTimeFraction_Set(
PyTime_t denom);

// Compute ticks * frac.numer / frac.denom.
// Clamp to [_PyTime_MIN; _PyTime_MAX] on overflow.
// Clamp to [PyTime_MIN; PyTime_MAX] on overflow.
extern PyTime_t _PyTimeFraction_Mul(
PyTime_t ticks,
const _PyTimeFraction *frac);
Expand Down
2 changes: 1 addition & 1 deletion Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ thread_module_exec(PyObject *module)

// TIMEOUT_MAX
double timeout_max = (double)PY_TIMEOUT_MAX * 1e-6;
double time_max = PyTime_AsSecondsDouble(_PyTime_MAX);
double time_max = PyTime_AsSecondsDouble(PyTime_MAX);
timeout_max = Py_MIN(timeout_max, time_max);
// Round towards minus infinity
timeout_max = floor(timeout_max);
Expand Down
4 changes: 2 additions & 2 deletions Python/thread_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
if (microseconds >= 0) {
// bpo-41710: PyThread_acquire_lock_timed() cannot report timeout
// overflow to the caller, so clamp the timeout to
// [_PyTime_MIN, _PyTime_MAX].
// [PyTime_MIN, PyTime_MAX].
//
// _PyTime_MAX nanoseconds is around 292.3 years.
// PyTime_MAX nanoseconds is around 292.3 years.
//
// _thread.Lock.acquire() and _thread.RLock.acquire() raise an
// OverflowError if microseconds is greater than PY_TIMEOUT_MAX.
Expand Down