Skip to content

[3.15] gh-154836: Fix Popen.wait() with very large timeouts on the pidfd/kqueue wait paths (GH-154837) - #154891

Merged
gpshead merged 1 commit into
python:3.15from
miss-islington:backport-11d0da5-3.15
Jul 29, 2026
Merged

[3.15] gh-154836: Fix Popen.wait() with very large timeouts on the pidfd/kqueue wait paths (GH-154837)#154891
gpshead merged 1 commit into
python:3.15from
miss-islington:backport-11d0da5-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

The event-driven wait introduced by gh-83069 passes the caller's timeout
unclamped to poll() / kqueue.control(), so values that do not fit the C
timestamp conversion (float('inf'), sys.maxsize, 1e10, ...) raise
OverflowError on Linux and, on macOS/BSD, a misleading
"TypeError: timeout must be a real number or None" -- all of which
worked on 3.14 and earlier.

  • Lib/subprocess.py: clamp each wait to _MAXIMUM_WAIT_TIMEOUT (24h,
    following asyncio's MAXIMUM_SELECT_TIMEOUT precedent) and loop until
    the real deadline in both _wait_pidfd() and _wait_kqueue().
  • Modules/selectmodule.c: only rewrite the kqueue.control() timeout
    conversion failure into TypeError when the original exception IS a
    TypeError, exactly like the select()/poll()/devpoll()/epoll() sites,
    so OverflowError surfaces for out-of-range values.
    (cherry picked from commit 11d0da5)

Co-authored-by: Calvin Prewitt calvin@setout.dev
Co-authored-by: Claude Fable 5 noreply@anthropic.com

Fixes #154836

…fd/kqueue wait paths (pythonGH-154837)

The event-driven wait introduced by pythongh-83069 passes the caller's timeout
unclamped to poll() / kqueue.control(), so values that do not fit the C
timestamp conversion (float('inf'), sys.maxsize, 1e10, ...) raise
OverflowError on Linux and, on macOS/BSD, a misleading
"TypeError: timeout must be a real number or None" -- all of which
worked on 3.14 and earlier.

- Lib/subprocess.py: clamp each wait to _MAXIMUM_WAIT_TIMEOUT (24h,
  following asyncio's MAXIMUM_SELECT_TIMEOUT precedent) and loop until
  the real deadline in both _wait_pidfd() and _wait_kqueue().
- Modules/selectmodule.c: only rewrite the kqueue.control() timeout
  conversion failure into TypeError when the original exception IS a
  TypeError, exactly like the select()/poll()/devpoll()/epoll() sites,
  so OverflowError surfaces for out-of-range values.
(cherry picked from commit 11d0da5b54b1a162e8f2566675007cfb2db797b5)

Co-authored-by: Calvin Prewitt <calvin@setout.dev>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@miss-islington
miss-islington requested a review from gpshead as a code owner July 29, 2026 17:46
@gpshead
gpshead enabled auto-merge (squash) July 29, 2026 17:46
@gpshead gpshead self-assigned this Jul 29, 2026
@gpshead
gpshead merged commit dd2714d into python:3.15 Jul 29, 2026
54 of 55 checks passed
@miss-islington
miss-islington deleted the backport-11d0da5-3.15 branch July 29, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants