[I18n-sig] codecs module, readlines and xreadlines

Martin v. Löwis martin@v.loewis.de
16 Jan 2003 11:09:05 +0100


"M.-A. Lemburg" <mal@lemburg.com> writes:

> On Windows, the 'r' opens the file in text which mangles the line-end
> information. You should try to open the file in 'rb' (binary) mode
> for comparison.

The issue is, of course, that codecs.open is usually meant for text
data, so comparing 'r' to 'r' is fair, IMO.

> codecs.open() automatically appends the 'b' to the 'r' for you,
> so this is probably the cause of the problem.

That is an implementation detail which shouldn't be visible to the
user. I understand that it is necessary to open the underlying stream
in binary mode, but then the higher layers should hide that fact.

Regards,
Martin