From 25869d0af37078b9ad78fb39045ada0d075d13a6 Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Sun, 5 Apr 2026 07:48:29 +0800 Subject: [PATCH 1/6] fix: correct error message for stdout pipe check in run_process --- newsfragments/3409.bugfix.rst | 1 + src/trio/_subprocess.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 newsfragments/3409.bugfix.rst diff --git a/newsfragments/3409.bugfix.rst b/newsfragments/3409.bugfix.rst new file mode 100644 index 0000000000..9fbf7a228c --- /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 145c2de9b0..d73ba3dc23 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", ) From 6a2f6c82aa91294439c0751fc29cc1aeaad72163 Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Sun, 5 Apr 2026 23:15:11 +0800 Subject: [PATCH 2/6] fix: update test to match corrected stdin error message --- src/trio/_tests/test_subprocess.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/trio/_tests/test_subprocess.py b/src/trio/_tests/test_subprocess.py index 05ac69d3f2..d85cb19ae9 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(; use nursery\.start or pass the data you want to write directly)*$" with pytest.raises(ValueError, match=pipe_stdout_error): await run_process(CAT, stdout=subprocess.PIPE) with pytest.raises( From fa84ef0954b0cf638942b53c1b49bcc3ae4be1f7 Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Mon, 6 Apr 2026 11:06:24 +0800 Subject: [PATCH 3/6] fix: use double backticks in news fragment for RST code formatting --- newsfragments/3409.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/newsfragments/3409.bugfix.rst b/newsfragments/3409.bugfix.rst index 9fbf7a228c..09f70893cc 100644 --- a/newsfragments/3409.bugfix.rst +++ b/newsfragments/3409.bugfix.rst @@ -1 +1 @@ -Fixed incorrect error message in `run_process`: the `stdout` pipe check now correctly says "stdout" instead of "stdin". +Fixed incorrect error message in ``run_process``: the ``stdout`` pipe check now correctly says "stdout" instead of "stdin". From 97ba75cffeea372dce4817ceb73150a9fcab7f48 Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Mon, 6 Apr 2026 23:11:55 +0800 Subject: [PATCH 4/6] fix: use ? instead of * for more specific regex matching --- src/trio/_tests/test_subprocess.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/trio/_tests/test_subprocess.py b/src/trio/_tests/test_subprocess.py index d85cb19ae9..87cc2ed7de 100644 --- a/src/trio/_tests/test_subprocess.py +++ b/src/trio/_tests/test_subprocess.py @@ -367,10 +367,10 @@ async def test_run() -> None: with pytest.raises(UnicodeError): await run_process(CAT, stdin="oh no, it's text") - 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)*$" + 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(; use nursery\.start or pass the data you want to write directly)*$" + 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): await run_process(CAT, stdout=subprocess.PIPE) with pytest.raises( From 56fce55d1db29f642299864d4a2d2c1e51d379a8 Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Tue, 7 Apr 2026 11:04:26 +0800 Subject: [PATCH 5/6] fix: use exact match regex per review suggestion --- src/trio/_tests/test_subprocess.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/trio/_tests/test_subprocess.py b/src/trio/_tests/test_subprocess.py index 87cc2ed7de..a1a70e575d 100644 --- a/src/trio/_tests/test_subprocess.py +++ b/src/trio/_tests/test_subprocess.py @@ -367,10 +367,10 @@ async def test_run() -> None: with pytest.raises(UnicodeError): await run_process(CAT, stdin="oh no, it's text") - 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)?$" + 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(; use nursery\.start or pass the data you want to write directly)?$" + 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( From e7b02c6d650d5474d80f95c749caacefa9eb755d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Apr 2026 22:44:03 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- test-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index 89dde86634..506acfdc0d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -141,7 +141,7 @@ requests==2.33.1 # via sphinx roman-numerals==4.1.0 ; python_full_version >= '3.11' # via sphinx -ruff==0.15.8 +ruff==0.15.9 # via -r test-requirements.in sniffio==1.3.1 # via -r test-requirements.in @@ -203,7 +203,7 @@ typing-extensions==4.15.0 # virtualenv urllib3==2.6.3 # via requests -uv==0.11.2 +uv==0.11.3 # via -r test-requirements.in virtualenv==21.2.0 # via pre-commit