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
{{ message }}
Repository navigation
Setting Invalid sys.stdin in interactive mode => loop forever. #55939
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.
changed the title [-]Setting sys.stdin to an invalid input stream causes interpreter run loop forever.[/-][+]Setting Invalid sys.stdin in interactive mode => loop forever.[/+]on Apr 2, 2011
Activity
ysjray commentedon Mar 31, 2011
Setting sys.stdin to an invalid input stream under interactive mode causes interpreter run loop forever:
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.
[-]Setting sys.stdin to an invalid input stream causes interpreter run loop forever.[/-][+]Setting Invalid sys.stdin in interactive mode => loop forever.[/+]vstinner commentedon Apr 2, 2011
I think that it is a duplicate of bpo-8070.