[issue17620] Python interactive console doesn't use sys.stdin for input

Antoine Pitrou report at bugs.python.org
Thu Apr 11 11:56:36 CEST 2013


Antoine Pitrou added the comment:

> • interactive console doesn't use sys.stdin for input, why?

Modules/main.c calls PyRun_AnyFileFlags(stdin, "<stdin>", ...). At this point, sys.stdin *is* the same as C stdin by construction, so I'm not sure how you came to encounter the issue.

However, it's also true that if you later redirect sys.stdin, it will be ignored and the original C stdin (as passed to PyRun_InteractiveLoopFlags) will continue to be used. On the other hand, the input() implementation has dedicated logic to find out whether sys.stdin is the same as C stdin.

(by the way, the issue should also apply to 2.7)

> • it uses sys.stdin.encoding, shouldn't it rather use sys.__stdin__.encoding if anything?

Assuming the previous bug gets fixed, then no :-)

----------
nosy: +benjamin.peterson, brett.cannon, georg.brandl, ncoghlan
versions: +Python 2.7

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


More information about the Python-bugs-list mailing list