SIGN IN SIGN UP

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.
G
Gregory P. Smith committed
2754e9a615de298b0c3a97e0bfd65a7506ebf657
Parent: 1e7dfbc
Committed by GitHub <noreply@github.com> on 4/27/2026, 12:40:20 AM