Skip to content

input() doesn't print the prompt if stderr is redirected #92715

Open
@DavidNemeskey

Description

@DavidNemeskey

Bug report

If stderr is redirected, input() doesn't print the prompt. The same happens when stdout is redirected, but that is to be expected.

Code (in test.py):

x = input('prompt: ')
print(x)

When run:

> python test.py
prompt: text
text

> python test.py >out
text

> python test.py 2>err
text
text

The contents of out and err, respectively:

# out
prompt: text
# err
prompt: 

The first and second cases are as expected. In the last case, the prompt is not printed, even though it should go into stdout, according to the documentation. Instead, it is printed to err.

Your environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions