[Python-bugs-list] Ctrl-Z confuses readline on NT (PR#323)

Guido van Rossum guido@python.org
Wed, 10 May 2000 12:47:33 -0400


> 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
data character.

--Guido van Rossum (home page: http://www.python.org/~guido/)