Issues

Issue #150 new

Line ending handling broken on Win32 platform

guest
created an issue

Version 0.3.4

Line ending handling of templates is broken on Windows:

For each "CR-LF" sequence in the template file you get "CR-CR-LF" in the output.

This only happens when using the filename argument to Template.init(), not if the text argument is used to supply the template.

I think this is due to opening file with mode "rb" where mode "rU" should be used to automatically convert line endings to the correct internal format on all platforms.

Comments (2)

  1. Mike Bayer repo owner

    If I recall correctly, we needed "rb" for Python 3k ? any chance you can verify your fix for py3k ?

    Also, 'rU' only for the original template, but not the module source file ? there are four open() statements in _compile_from_file.

  2. guest reporter

    Replying to [comment:1 zzzeek]:

    If I recall correctly, we needed "rb" for Python 3k ? any chance you can verify your fix for py3k ?

    Py3k docs says 'U' mode is available for backwards compatibility. I have no capability to test, as I am still using Py2.6

    Also, 'rU' only for the original template, but not the module source file ? there are four open() statements in _compile_from_file.

    I would use it for all text files that get open()ed.

  3. Log in to comment