gh-110014: Remove PY_TIMEOUT_MAX from limited C API (#110217) · python/cpython@4d0d1c3 (original) (raw)
8 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1290,3 +1290,6 @@ removed, although there is currently no date scheduled for their removal. | ||
1290 | 1290 | * :c:func:`PyThread_get_key_value`: use :c:func:`PyThread_tss_get`. |
1291 | 1291 | * :c:func:`PyThread_delete_key_value`: use :c:func:`PyThread_tss_delete`. |
1292 | 1292 | * :c:func:`PyThread_ReInitTLS`: no longer needed. |
1293 | + | |
1294 | +* Remove undocumented ``PY_TIMEOUT_MAX`` constant from the limited C API. | |
1295 | + (Contributed by Victor Stinner in :gh:`110014`.) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,6 +2,14 @@ | ||
2 | 2 | # error "this header file must not be included directly" |
3 | 3 | #endif |
4 | 4 | |
5 | +// PY_TIMEOUT_MAX is the highest usable value (in microseconds) of PY_TIMEOUT_T | |
6 | +// type, and depends on the system threading API. | |
7 | +// | |
8 | +// NOTE: this isn't the same value as `_thread.TIMEOUT_MAX`. The _thread module | |
9 | +// exposes a higher-level API, with timeouts expressed in seconds and | |
10 | +// floating-point numbers allowed. | |
11 | +PyAPI_DATA(const long long) PY_TIMEOUT_MAX; | |
12 | + | |
5 | 13 | #define PYTHREAD_INVALID_THREAD_ID ((unsigned long)-1) |
6 | 14 | |
7 | 15 | #ifdef HAVE_PTHREAD_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -33,27 +33,18 @@ PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); | ||
33 | 33 | #define WAIT_LOCK 1 |
34 | 34 | #define NOWAIT_LOCK 0 |
35 | 35 | |
36 | -/* PY_TIMEOUT_T is the integral type used to specify timeouts when waiting | |
37 | - on a lock (see PyThread_acquire_lock_timed() below). | |
38 | - PY_TIMEOUT_MAX is the highest usable value (in microseconds) of that | |
39 | - type, and depends on the system threading API. | |
40 | - | |
41 | - NOTE: this isn't the same value as `_thread.TIMEOUT_MAX`. The _thread | |
42 | - module exposes a higher-level API, with timeouts expressed in seconds | |
43 | - and floating-point numbers allowed. | |
44 | -*/ | |
36 | +// PY_TIMEOUT_T is the integral type used to specify timeouts when waiting | |
37 | +// on a lock (see PyThread_acquire_lock_timed() below). | |
45 | 38 | #define PY_TIMEOUT_T long long |
46 | 39 | |
47 | -PyAPI_DATA(const long long) PY_TIMEOUT_MAX; | |
48 | - | |
49 | 40 | |
50 | 41 | /* If microseconds == 0, the call is non-blocking: it returns immediately |
51 | 42 | even when the lock can't be acquired. |
52 | 43 | If microseconds > 0, the call waits up to the specified duration. |
53 | 44 | If microseconds < 0, the call waits until success (or abnormal failure) |
54 | 45 | |
55 | - microseconds must be less than PY_TIMEOUT_MAX. Behaviour otherwise is | |
56 | - undefined. | |
46 | + If *microseconds* is greater than PY_TIMEOUT_MAX, clamp the timeout to | |
47 | + PY_TIMEOUT_MAX microseconds. | |
57 | 48 | |
58 | 49 | If intr_flag is true and the acquire is interrupted by a signal, then the |
59 | 50 | call will return PY_LOCK_INTR. The caller may reattempt to acquire the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 | +Remove undocumented ``PY_TIMEOUT_MAX`` constant from the limited C API. | |
2 | +Patch by Victor Stinner. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1843,10 +1843,6 @@ | ||
1843 | 1843 | [function.PyThread_start_new_thread] |
1844 | 1844 | added = '3.2' |
1845 | 1845 | |
1846 | -# Not mentioned in PEP 384, was implemented as a macro in Python <= 3.12 | |
1847 | -[data.PY_TIMEOUT_MAX] | |
1848 | -added = '3.2' | |
1849 | - | |
1850 | 1846 | # The following were added in PC/python3.def in Python 3.3: |
1851 | 1847 | # 7800f75827b1be557be16f3b18f5170fbf9fae08 |
1852 | 1848 | # 9c56409d3353b8cd4cfc19e0467bbe23fd34fc92 |