Author ysj.ray
Recipients ysj.ray
Date 2011-03-31.15:17:18
SpamBayes Score 2.07317e-12
Marked as misclassified No
Message-id <1301584644.8.0.189290691333.issue11730@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-03-31 15:17:24ysj.raysetrecipients: + ysj.ray
2011-03-31 15:17:24ysj.raysetmessageid: <1301584644.8.0.189290691333.issue11730@psf.upfronthosting.co.za>
2011-03-31 15:17:18ysj.raylinkissue11730 messages
2011-03-31 15:17:18ysj.raycreate