[Python-bugs-list] Ctrl-Z confuses readline on NT (PR#323)
Wed, 10 May 2000 12:50:57 -0400 (EDT)
> This may not be a Python bug, in that it probably reflects ancient
> MSDOS conventions that live on inside NT, but I would expect (hope?)
> Python to work round it...
> When reading a file (a mail spool file in some strange format) via a
> file object, using readline, Ctrl-Z caused serious problems:
> - in the midle of a line, the rest of the line was not read
> - at the start of a line, it was taken as EOF
> I tried searching on the bugs dbase (as I guess this is already
> known, but found nothing under "Control Z" etc).
> Once I realised the problem, it was easy to fix of course - so if there
> is no work-round for Python, maybe it could be mentioned in the docs?
> It might save someone else an hour or two...
The stdandard I/O library is "helping".
Use open(filename, "rb") to open the file in binary mode. You will
have to deal with CRLF yourself then, but ^Z will be a regular plain
--Guido van Rossum (home page: http://www.python.org/~guido/)