[issue15068] fileinput requires two EOF when reading stdin

Zachary Ware report at bugs.python.org
Thu Jun 14 19:14:50 CEST 2012


Zachary Ware <zachary.ware at gmail.com> added the comment:

I just tested on Python 3.2, and found something interesting; it seems a ^Z character on a line that has other input read in as a character.  Also, other input after an EOF on its own means you still have to do two more EOFs to end.

Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import fileinput
>>> lines = list(fileinput.input())
test
testing
^Z
^Z
>>> lines
['test\n', 'testing\n']
>>> lines = list(fileinput.input())
test
testing^Z
^Z
^Z
>>> lines
['test\n', 'testing\x1a\n']
>>> lines = list(fileinput.input())
testing^Z
test
^Z
testing
^Z
^Z
>>> lines
['testing\x1a\n', 'test\n', 'testing\n']

Also, the documentation for fileinput doesn't mention EOF at all.

----------
nosy: +zach.ware
versions: +Python 3.2, Python 3.3

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


More information about the Python-bugs-list mailing list