Skip to content

gh-131064: Handle closed pipes consistently in communicate - #159855

Open
limadog9 wants to merge 1 commit into
python:mainfrom
limadog9:gh-131064-communicate-closed-pipes
Open

limadog9 wants to merge 1 commit into
python:mainfrom
limadog9:gh-131064-communicate-closed-pipes

Conversation

@limadog9

@limadog9 limadog9 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Make Popen.communicate() handle already-closed pipes consistently across its optimized path, selector path, and Windows reader threads. Closed output pipes return the same empty bytes or string that the selector path already returned, and closed stdin is not written to.

Add regressions covering stdout and stderr, one or multiple pipes, binary and text modes, and calls with and without timeouts. Set the existing broken-pipe mock's closed state explicitly so it continues to exercise writes to an open pipe.

Fixes #131064.

Validation:

  • The new regressions reproduce six failing cases before the fix.
  • Full subprocess suite on a free-threaded debug build: 375 tests, 48 skipped.
  • Focused regressions also pass on a GIL debug build.
  • Ruff, NEWS lint, and patchcheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent Popen.communicate() behavior if stdin/stdout/stderr is closed PIPE

1 participant