-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
input() doesn't print the prompt if stderr is redirected #92715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is probably a duplicate of: Also related: |
I checked the first issue superficially, and I am not really sure it is a duplicate. Eryk's answer in the thread referenced in the penultimate comment, on the other hand, might explain what I have experienced ( So in a sense this might be duplicate (of the thread at least), but the second last comment on that is from 6 years ago, so I don't know if that issue is considered being "alive". |
To fix this you can ipanov@archlinux ~/u/sandbox > cat test_stderr.py
input_msg = input('Enter text: ')
print(input_msg)
ipanov@archlinux ~/u/sandbox > python test_stderr.py 2>> out.txt
123
123
ipanov@archlinux ~/u/sandbox > and with fix: ipanov@archlinux ~/u/sandbox > cat test_stderr.py
import readline
input_msg = input('Enter text: ')
print(input_msg)
ipanov@archlinux ~/u/sandbox > python test_stderr.py 2>> out.txt
Enter text: 123
123
ipanov@archlinux ~/u/sandbox > |
@headst1337 Thank you; it's good to know that |
Bug report
If
stderr
is redirected,input()
doesn't print the prompt. The same happens whenstdout
is redirected, but that is to be expected.Code (in
test.py
):When run:
The contents of
out
anderr
, respectively: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 toerr
.Your environment
Show Source
link to GitHub #44~20.04.2-Ubuntu SMP Tue Oct 26 18:07:44 UTC 2021 x86_64 x86_64 x86_64 GNU/LinuxThe text was updated successfully, but these errors were encountered: