Skip to content

subprocess.run timeout does not function if shell=True and capture_output=True #121157

Open
@Mabeeck

Description

@Mabeeck

Bug report

Bug description:

I am using python 3.12.4 on windows 10 and when calling subprocess.run("powershell", shell=True, capture_output=True, timeout=1) code execution seems to suspend indefinetly as the process now accepts the user input and interprets it.

This behaviour matches the one described in #81605 despite it having supposedly been fixed 5 years ago.
For example when calling subprocess.run("cmd", shell=True, capture_output=True, timeout=1) and then entering echo o>f.txt a new file called "f.txt" gets created with "o" as its content.

When using the IDLE Shell the process completes nearly instandly and returns this:

CompletedProcess(args='powershell', returncode=0, stdout=b'Windows PowerShell\r\nCopyright (C) Microsoft Corporation. Alle Rechte vorbehalten.\r\n\r\nLernen Sie das neue plattform\x81bergreifende PowerShell kennen - https://aka.ms/pscore6\r\n\r\nPS C:\Users\Mabeeck\Desktop\Python> ', stderr=b'')

The same applies for Python 3.8.9, 3.9.2, 3.10.6, 3.11.5 and 3.13.0b3
I'll apoligise in advance, if my impression of the bug beeing supposed to be fixed is wrong.

CPython versions tested on:

3.8, 3.9, 3.10, 3.11, 3.12, 3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-subprocessSubprocess issues.type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions