diff --git a/newsfragments/3409.bugfix.rst b/newsfragments/3409.bugfix.rst new file mode 100644 index 000000000..09f70893c --- /dev/null +++ b/newsfragments/3409.bugfix.rst @@ -0,0 +1 @@ +Fixed incorrect error message in ``run_process``: the ``stdout`` pipe check now correctly says "stdout" instead of "stdin". diff --git a/src/trio/_subprocess.py b/src/trio/_subprocess.py index 145c2de9b..d73ba3dc2 100644 --- a/src/trio/_subprocess.py +++ b/src/trio/_subprocess.py @@ -675,7 +675,7 @@ async def my_deliver_cancel(process): if task_status is trio.TASK_STATUS_IGNORED: if stdin is subprocess.PIPE: raise ValueError( - "stdout=subprocess.PIPE is only valid with nursery.start, " + "stdin=subprocess.PIPE is only valid with nursery.start, " "since that's the only way to access the pipe; use nursery.start " "or pass the data you want to write directly", ) diff --git a/src/trio/_tests/test_subprocess.py b/src/trio/_tests/test_subprocess.py index 05ac69d3f..a1a70e575 100644 --- a/src/trio/_tests/test_subprocess.py +++ b/src/trio/_tests/test_subprocess.py @@ -367,9 +367,10 @@ async def test_run() -> None: with pytest.raises(UnicodeError): await run_process(CAT, stdin="oh no, it's text") - pipe_stdout_error = r"^stdout=subprocess\.PIPE is only valid with nursery\.start, since that's the only way to access the pipe(; use nursery\.start or pass the data you want to write directly)*$" - with pytest.raises(ValueError, match=pipe_stdout_error): + pipe_stdin_error = r"^stdin=subprocess\.PIPE is only valid with nursery\.start, since that's the only way to access the pipe; use nursery\.start or pass the data you want to write directly$" + with pytest.raises(ValueError, match=pipe_stdin_error): await run_process(CAT, stdin=subprocess.PIPE) + pipe_stdout_error = r"^stdout=subprocess\.PIPE is only valid with nursery\.start, since that's the only way to access the pipe$" with pytest.raises(ValueError, match=pipe_stdout_error): await run_process(CAT, stdout=subprocess.PIPE) with pytest.raises(