[issue21104] Read from file aborted

eryksun report at bugs.python.org
Sun Mar 30 23:26:33 CEST 2014


eryksun added the comment:

AFAIK, this doesn't affect Python 3 under normal circumstances. A file could be manually set to text mode by calling msvcrt.setmode(f.fileno(), os.O_TEXT), but that's out of the norm.

In Python 2, on Windows interpreting ctrl+z (0x1a) as end-of-file is normal behavior in text mode. Read the remarks about [t]ext mode in the description of Microsoft's fopen implementation:

http://msdn.microsoft.com/en-us/library/yeby3zcb%28v=vs.90%29.aspx

If you use Python's universal newlines mode, e.g. open('sample.txt', 'rU'), then the underlying file is opened in binary mode and therefore will not interpret ctrl+z as the end-of-file marker.

----------
nosy: +eryksun

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


More information about the Python-bugs-list mailing list