Josh Rosenberg <shadowranger+pyt...@gmail.com> added the comment:

For those who find this in the future, the simplest workaround for the:

for line in sys.stdin:

issue on Python 2 is to replace it with:

for line in iter(sys.stdin.readline, ''):

The problem is caused by the way file.__next__'s buffering behaves, but 
file.readline doesn't use that code (it delegates to either fgets or a loop 
over getc/getc_unlocked that never overbuffers beyond the newline). Two-arg 
iter lets you make an iterator that calls readline each time you want a line, 
and considers a return of '' (which is what readline returns when you hit EOF) 
to terminate iteration.

----------
nosy: +josh.r

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue26290>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to