line endings and Cygwin

Fredrik Lundh fredrik at pythonware.com
Wed Apr 13 09:05:53 BST 2005


Martin Pool wrote:

> > May I suggest that all files below .bzr should be opened in binary mode
> > only - readlines() and friends under win32 handle this just fine, and
> > this way it is easy to copy files around. This is also especially
> > important if your repo is on a FAT mounted partion and gets accessed
> > from multiple operating systems.
>
> Just to be clear, do you mean that readlines() on Windows will do the
> right thing on a file with only \n markers, even if it's opened in
> binary mode?

yes.  opening files with the "b" flag switches off \r\n <=> \n conversion, but all
text-oriented methods will still work properly (i.e. treat \n as a line break).

I suggest sticking to

    "rb" and "wb" for all binary files, and for files with "opaque" contents
    "rb" and "wb" for text files that are created and maintained by bzr itself
    "rU" and "wU" (or maybe just "r" and "w"), for text files from external sources

</F> 







More information about the bazaar mailing list