]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-47798: Refactor the POSIX subprocess.Popen._communicate selector loop into helpers...
authorGregory P. Smith <68491+gpshead@users.noreply.github.com>
Mon, 27 Apr 2026 00:40:20 +0000 (17:40 -0700)
committerGitHub <noreply@github.com>
Mon, 27 Apr 2026 00:40:20 +0000 (00:40 +0000)
commit2754e9a615de298b0c3a97e0bfd65a7506ebf657
treeb4e1d76a985ab5530bff88bf2735309a05168fce
parent1e7dfbce930d6abd4e5453961c4f0fe4c6ade08e
gh-47798: Refactor the POSIX subprocess.Popen._communicate selector loop into helpers (GH-149032)

No public API change.  Lift the per-iteration select/read/write loop out of
Popen._communicate (POSIX) into a module-level _communicate_io_posix(), with
small _flush_stdin / _make_input_view / _translate_newlines helpers alongside
it.  Popen._communicate calls the helper and persists the returned input
offset for resume-after-timeout.

Retire the private Popen._remaining_time method in favor of module-level
_deadline_remaining; all call sites (POSIX and Windows) updated.

Defensive behavioural deltas: the stdin and stdout/stderr .close() calls in
the I/O loop now swallow BrokenPipeError / OSError, matching __exit__ and the
no-input path; previously these were bare.

Adds test_communicate_timeout_resume_partial_write to cover _input_offset
bookkeeping across TimeoutExpired/resume.
Lib/subprocess.py
Lib/test/test_subprocess.py