[New-bugs-announce] [issue11730] Setting sys.stdin to an invalid input stream causes interpreter run loop forever.

ysj.ray report at bugs.python.org
Thu Mar 31 17:17:24 CEST 2011


New submission from ysj.ray <ysj.ray at gmail.com>:

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.

----------
components: Interpreter Core
messages: 132678
nosy: ysj.ray
priority: normal
severity: normal
status: open
title: Setting sys.stdin to an invalid input stream causes interpreter run loop forever.
type: crash
versions: Python 3.1, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11730>
_______________________________________


More information about the New-bugs-announce mailing list