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
IDLE and Command line present different behavior for sys.stdin #53536
Comments
The fact that in IDLE sys.stdin is a idlelib.rpc.RPCProxy results in programs having different behavior in IDLE and in Command Line mode. I noticed that when grading many students exercises in IDLE. Things like: sys.stdin.readlines() just don´t exists in IDLE, but are fully operational in Command Line mode. In Command Line mode, sys.stdin is a file. This is expected, as the manual (27.1) says that sys.stdin (and stdout and stderrr) are "File objects corresponding to the interpreter’s standard input" There are also other "quirks". I fell that is really strange that stdin has different behavior for the same program. |
I agree that the wrapping of these in IDLE should be as transparent as possible. It would be helpful if you could specify what other "quirks" you have found regarding sys.stdin, sys.stdout and sys.stderr, preferably describing use cases where these are problematic. |
Other quirks apparently caused by this bug: msvcrt.getch() does not block and wait for a keypress in IDLE. Returns immediately with b'\xff'. Some of the suggested usage in the manual for sys.stdin does not work under IDLE. E.g. sys.stdin.detach() doesn't work in IDLE. On this last point, the manual has a caveat in the last line of the sys.stdin description that could exonerate it. Regardless, the behavior is inconsistent and makes for awkward UI when using IDLE. |
msvcrt.getwch has a similar failure, returning (2**16)-1. Because of this, getpass.win_getpass (used as getpass.getpass on windows) echoes the password when using Idle (even without a subprocess), but does not echo passwords when from a command-line python. |
The proposed patches make the behavior of sys.std* files in IDLE more similar to the behavior of sys.std* files in standard interpreter. Now sys.stdin have read() and readlines() methods. The source code is simplified. |
I tried the patch for 3.3 and it works for me on Linux. It correctly handles prior issues like bpo-13532, bpo-15318, bpo-15319, and bpo-7163, as well as providing good support for .read, .readline, .readlines. Each of those methods respond correctly to Ctrl+C and Ctrl+D. On Windows 7, with 2.7.3, Ctrl+D is still needed to indicate end-of-file, instead of Ctrl+Z. This may or may not be significant, but it is related to bpo-14735. |
I agree with the goal. We need an automated test for these proxies. |
Unfortunately we have not a unittest framework for IDLE yet. After implementing bpo-15392 I will make tests for these proxies. |
If no one objects, I'm going to commit this next week. |
New changeset def4cd7e0a9f by Serhiy Storchaka in branch '2.7': New changeset 0d26f3aa7a8f by Serhiy Storchaka in branch '3.2': New changeset 9dfbd65d5041 by Serhiy Storchaka in branch '3.3': New changeset 458b36fb12bc by Serhiy Storchaka in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: