Yonatan Zunger <zun...@humu.com> 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", "credits" or "license" for more information. (InteractiveConsole) >>> Traceback (most recent call last): File "./test.py", line 6, in <module> code.InteractiveConsole().interact() File "/Users/zunger/.pyenv/versions/3.6.2/lib/python3.6/code.py", line 228, in interact line = self.raw_input(prompt) File "/Users/zunger/.pyenv/versions/3.6.2/lib/python3.6/code.py", line 275, in raw_input return input(prompt) ValueError: I/O operation on closed file. - ^D and raise SystemExit in console both yield: 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", "credits" or "license" for more information. (InteractiveConsole) >>> ^D now exiting InteractiveConsole... Try 0: closed is False 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", "credits" or "license" for more information. (InteractiveConsole) >>> ^D now exiting InteractiveConsole... Try 1: closed is False So it looks like the issue is specific to quit(), as you say. I'm not sure I understand what the purpose of the sys.stdin.close() call is, though: why would we *want* to alert the parent shell in some way beyond a SystemExit as the default (non-overrideable) behavior? This may be a documentation issue, but it seems extremely surprising to me; no other function does this additional thing, even when raising a SystemExit. I would think that any caller which is running InteractiveConsole.interact() and also wants to do something when it finishes would want to handle that additional logic itself. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34115> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com