Yonatan Zunger added the comment:
Eryk: Thanks for finding that! So that I'm sure I understand, if 34187 is
resolved, does that mean the stdin.close() is no longer required at all in
_Quitter?
On Sun, Jul 22, 2018 at 2:12 AM Eryk Sun wrote:
>
> Eryk Sun added the comment:
>
> > On Windows C
Eryk Sun added the comment:
> On Windows Console, sys.stdin.close() does not prevent a second
> interact call. This might be considered a bug.
This is a bug in io._WindowsConsoleIO.
In Python 3, the sys.std* file objects that get created at startup use
closefd=False:
>>> sys.stdin.bu
Yonatan Zunger added the comment:
Definitely agree about the difference.
I'd say that either SystemExit or EOFError would be a reasonable thing for
the interactive session to do, but the combination of closing stdin and
SystemExit is really weird. Honestly, I would have just expected interact(
Terry J. Reedy added the comment:
There is an important difference between a program saying 'I am done executing'
and a user saying 'I am done with the interactive session'. This is especially
true in an IDE where 'session' can include many editing and shell sessions.
'Stop executing' happ
Yonatan Zunger added the comment:
Or perhaps in an alternate phrasing: The sys.stdin.close behavior makes sense
if quit is being used inside IDLE, but is very surprising from the perspective
of the `code` module. (Really, even the SystemExit is surprising there, and
should be documented!)
W
Yonatan Zunger added the comment:
Testing your code sample on OS X (10.13.6) with Python 3.6.2:
- quit() in the console yields
Exc 0: closed is True
Python 3.6.2 (default, Apr 17 2018, 12:29:33)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "c
Terry J. Reedy added the comment:
To investigate your claim about closing sys.stdin, I ran the following on
Windows 10, mostly with 3.7.0, in both the console and IDLE, using various exit
methods.
import code
import sys
for i in range(2):
try:
code.InteractiveConsole().interact(
New submission from Yonatan Zunger :
code.InteractiveConsole.interact() closes stdin on exit, which can be very
surprising to successive code, not least future calls to interact(). A simple
repro with a workaround is:
import code
import io
import os
import sys
def run():
print(sys.stdin.