codecs.open on Win32 -- converting my newlines to CR+LF

Chris Rebert clp2 at rebertia.com
Thu Aug 27 08:11:22 CEST 2009


On Wed, Aug 26, 2009 at 11:06 PM, Chris Rebert<clp2 at rebertia.com> wrote:
> On Wed, Aug 26, 2009 at 8:40 PM, Ryan McGuire<usenet at enigmacurry.com> wrote:
>> On Aug 26, 11:04 pm, Philip Semanchuk <phi... at semanchuk.com> wrote:
>>> Try using "rb" instead of "r" for the mode in the call to open().
>>>
>>> HTH
>>> Philip
>>
>> That does indeed fix the problem, thanks! Still seems like the docs
>> are wrong though.
>
> Yeah, the need to specify "b" does seem rather incongruous:
>
> codecs.open(filename, mode[, encoding[, errors[, buffering]]])
>    [...]
>    Note: Files are always opened in binary mode, even if no binary
> mode was specified. This is done to avoid data loss due to encodings
> using 8-bit values. This means that no automatic conversion of b'\n'
> is done on reading and writing.
>
> File a bug perhaps?: http://bugs.python.org/

Ah, I see you already did: http://bugs.python.org/issue6788

- Chris



More information about the Python-list mailing list