This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Setting Invalid sys.stdin in interactive mode => loop forever.
Type: crash Stage: needs patch
Components: Interpreter Core Versions: Python 3.1, Python 3.2, Python 3.3
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: vstinner, ysj.ray
Priority: normal Keywords:

Created on 2011-03-31 15:17 by ysj.ray, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg132678 - (view) Author: ysj.ray (ysj.ray) Date: 2011-03-31 15:17
Setting sys.stdin to an invalid input stream under interactive mode causes interpreter run loop forever:

Python 3.3a0 (default:22ae2b002865+, Mar 30 2011, 21:17:03) 
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
[57804 refs]
>>> sys.stdin = None
[57809 refs]
[57809 refs]
[57809 refs]
[57809 refs]
[57809 refs]

Not only setting to None but also to any other invalid input stream could cause this. It's because in the beginning of PyRun_InteractiveOneFlags(), in order to get stdin encoding, the code tries to get sys.stdin and check if it's valid(not NULL, not None, has "encoding" attribute), if not, return -1 directly, then the loop in PyRun_InteractLoopFlags() continues and does the same thing. I think this should be fixed by using the Py_FileSystemDefaultEncoding instead when sys.stdin is invalid.
msg132789 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-04-02 08:28
I think that it is a duplicate of #8070.
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55939
2011-04-02 08:28:53vstinnersetstatus: open -> closed
resolution: duplicate
messages: + msg132789
2011-04-02 05:21:27ned.deilysetnosy: + vstinner

stage: test needed -> needs patch
2011-04-02 01:13:28terry.reedysettitle: Setting sys.stdin to an invalid input stream causes interpreter run loop forever. -> Setting Invalid sys.stdin in interactive mode => loop forever.
stage: test needed
2011-03-31 15:17:18ysj.raycreate