You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per Martin's request in msg165197, this issue has been separated from bpo-13532.
The newly introduced _RPCFile object in run.py (422242dbce30) inherits from io.TextIOBase which has "readline" as one of its methods. As a result, IDLE's internal call readline are not handled properly.
The stdin_fix.patch provides a fix for readline and isatty.
I agree that the _RPCFile wrapping of the stdin proxy should be undone unless and until there is a positive reason for it -- it solves a problem -- and it is better tested. But reversion does not solve pre-existing problems. As noted by Roger, sys.stdin writes, which it should not do. Worse, when directly used, it does not read, which it should do.
>>> sys.stdin.read()
abcdefg
^Z
'abcdefg\n'
>>> sys.stdin.write('abc')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
io.UnsupportedOperation: not writable
Same difference for readlines and writelines. I wonder how input works if it does not call sys.stdin.read()
I found this in rpc.py:
# XXX KBK 09Sep03 We need a proper unit test for this module.
# Previously existing test code was removed at Rev 1.27 (r34098).
serwy commented on Jul 11, 2012
serwymannequin
MannequinAuthor
More actions
Including bpo-15318 where stdin is writable. The proper solution to that issue and this one are likely the same.
serwy commented on Jul 11, 2012
serwymannequin
MannequinAuthor
More actions
Same difference for readlines and writelines. I wonder how input works if it does not call sys.stdin.read()
Eventually IDLE makes a call to PyShell's readline.
Ah, sys.stdin.readline() works. So the object being proxied has readline (and write and writelines) but not read and readlines. I presume the proxy is in the user process and the actual stdin/out/err objects are in the idle process, interacting with the screen and keyboard via tkinter. Do you know what and where it is, so that we could look at it?
changed the title [-]IDLE - input() is broken.[/-][+]IDLE - sys.stdin is broken.[/+]on Jul 11, 2012
serwy commented on Jul 11, 2012
serwymannequin
MannequinAuthor
More actions
PyShell.py's PyShell object has the readline method, at line 1080 in the most recent code. It's meant for use with and without a subprocess. (See also bpo-14254)
The IDLEfork project long ago created the subprocess and the RPC plumbing for the subprocess interaction with the *existing* PyShell(OutputWindow) object as stdin/stdout/stderr. This RPC, found in rpc.py, is used in run.py and PyShell's ModifiedInterpreter. The start_subprocess method connects the stdin/stdout/stderr from the IDLE front-end to the subprocess in run.py. The stdout/stderr objects are the PyShell(OutputWindow) object wrapped by PseudoFile. Stdin is not wrapped, but it should be.
I know that this issue deals with stdin specifically, but I hope that the additional stdout/stderr information places the problem into a greater context.
loewis commented on Jul 11, 2012
loewismannequin
Mannequin
More actions
I think the issue is grossly underspecified. The title of the issue is "sys.stdin is broken" which says nothing about the way in which it is broken. Taking Roger's literal description, and his msg165191, the complaint is that input() no longer works, as doesn't readline and isatty.
Since this was what Roger opened the issue for, I declare this to be the issue being dealt with here. I agree that Serhiy's patch is a proper resolution of the issue.
Roger, please refrain from trying to put issues in a broader scope, unless you make an explicit specification what exactly is in scope and what is out of scope. I readily agree that there are many issues with stdin and stdout in IDLE; I don't agree that easily that they all deserve being resolved. I entirely, completely, absolutely disagree that they are related to what you originally submitted as this issue, as I firmly, deeply convinced believe that the fixes to the other issues will be different from the proper fix to this issue. So please, please, please don't mix issues.
Activity
serwy commentedon Jul 10, 2012
Per Martin's request in msg165197, this issue has been separated from bpo-13532.
The newly introduced _RPCFile object in run.py (422242dbce30) inherits from io.TextIOBase which has "readline" as one of its methods. As a result, IDLE's internal call readline are not handled properly.
The stdin_fix.patch provides a fix for readline and isatty.
serhiy-storchaka commentedon Jul 10, 2012
There is a simpler solution of this issue.
serwy commentedon Jul 10, 2012
I like Serhiy's patch. It works for me.
terryjreedy commentedon Jul 11, 2012
I agree that the _RPCFile wrapping of the stdin proxy should be undone unless and until there is a positive reason for it -- it solves a problem -- and it is better tested. But reversion does not solve pre-existing problems. As noted by Roger, sys.stdin writes, which it should not do. Worse, when directly used, it does not read, which it should do.
versus, in command interpreter (Win7,3.3.0b0)
>>> sys.stdin.read() abcdefg ^Z 'abcdefg\n' >>> sys.stdin.write('abc') Traceback (most recent call last): File "<stdin>", line 1, in <module> io.UnsupportedOperation: not writableSame difference for readlines and writelines. I wonder how input works if it does not call sys.stdin.read()
I found this in rpc.py:
# XXX KBK 09Sep03 We need a proper unit test for this module.
# Previously existing test code was removed at Rev 1.27 (r34098).
serwy commentedon Jul 11, 2012
Including bpo-15318 where stdin is writable. The proper solution to that issue and this one are likely the same.
serwy commentedon Jul 11, 2012
Eventually IDLE makes a call to PyShell's readline.
terryjreedy commentedon Jul 11, 2012
Ah, sys.stdin.readline() works. So the object being proxied has readline (and write and writelines) but not read and readlines. I presume the proxy is in the user process and the actual stdin/out/err objects are in the idle process, interacting with the screen and keyboard via tkinter. Do you know what and where it is, so that we could look at it?
[-]IDLE - input() is broken.[/-][+]IDLE - sys.stdin is broken.[/+]serwy commentedon Jul 11, 2012
PyShell.py's PyShell object has the readline method, at line 1080 in the most recent code. It's meant for use with and without a subprocess. (See also bpo-14254)
The IDLEfork project long ago created the subprocess and the RPC plumbing for the subprocess interaction with the *existing* PyShell(OutputWindow) object as stdin/stdout/stderr. This RPC, found in rpc.py, is used in run.py and PyShell's ModifiedInterpreter. The start_subprocess method connects the stdin/stdout/stderr from the IDLE front-end to the subprocess in run.py. The stdout/stderr objects are the PyShell(OutputWindow) object wrapped by PseudoFile. Stdin is not wrapped, but it should be.
I know that this issue deals with stdin specifically, but I hope that the additional stdout/stderr information places the problem into a greater context.
loewis commentedon Jul 11, 2012
I think the issue is grossly underspecified. The title of the issue is "sys.stdin is broken" which says nothing about the way in which it is broken. Taking Roger's literal description, and his msg165191, the complaint is that input() no longer works, as doesn't readline and isatty.
Since this was what Roger opened the issue for, I declare this to be the issue being dealt with here. I agree that Serhiy's patch is a proper resolution of the issue.
Roger, please refrain from trying to put issues in a broader scope, unless you make an explicit specification what exactly is in scope and what is out of scope. I readily agree that there are many issues with stdin and stdout in IDLE; I don't agree that easily that they all deserve being resolved. I entirely, completely, absolutely disagree that they are related to what you originally submitted as this issue, as I firmly, deeply convinced believe that the fixes to the other issues will be different from the proper fix to this issue. So please, please, please don't mix issues.
[-]IDLE - sys.stdin is broken.[/-][+]IDLE - readline, isatty, and input broken[/+]python-dev commentedon Jul 11, 2012
New changeset b90482742ee0 by Martin v. Löwis in branch '3.2':
Issue bpo-15319: Revert wrapping of sys.stdin. Patch by Serhiy Storchaka.
http://hg.python.org/cpython/rev/b90482742ee0
python-dev commentedon Jul 11, 2012
New changeset 42424c1f605c by Martin v. Löwis in branch '2.7':
Issue bpo-15319: Revert wrapping of sys.stdin. Patch by Serhiy Storchaka.
http://hg.python.org/cpython/rev/42424c1f605c
serhiy-storchaka commentedon Jul 11, 2012
Well, now, with the modified header, I'm not going to open a separate
issue. Here is a patch that fixes almost all IDLE sys.std* issues.
[-]IDLE - readline, isatty, and input broken[/-][+]IDLE - sys.stdin, sys.stdout, etc are broken[/+]loewis commentedon Jul 11, 2012
Serhiy: this issue is closed, so your patch won't be considered.
serhiy-storchaka commentedon Jul 11, 2012
Sorry, I missed the morning's discussion.
[-]IDLE - sys.stdin, sys.stdout, etc are broken[/-][+]IDLE - readline, isatty, and input broken[/+]