Skip to content

pytester.run(stdin=<bytes>) raises BrokenPipeError / can block when the child doesn't read stdin #15472

Backlog

Description

@RonnyPfannschmidt

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

For stdin=<bytes>, Pytester.popen() opens a pipe and does a blocking popen.stdin.write(stdin) before run() starts waiting with its timeout.

  • Child exits without reading: BrokenPipeError instead of a RunResult with the child's exit code.
  • Input larger than the pipe buffer (~64 KiB) and child not reading: the write blocks, so timeout= is never enforced.
pytester.run(sys.executable, "-c", "raise SystemExit(7)", stdin=b"x" * 2**20)
# expected ret == 7

Low priority (no user report). Any fix should cover popen() as well as run(). Found via #15470.

Activity

  1. added
    type: bug
    plugin: pytester
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: pytestertype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions