mako
mako copied to clipboard
Line ending handling broken on Win32 platform
Migrated issue, originally created by Anonymous
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.
Michael Bayer (@zzzeek) wrote:
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.
Anonymous wrote:
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.
Matthis Thorade (@thorade) wrote:
Looks like I am running into this issue, too, but I don't understand whether it is a Windows/Linux problem, or whether it is a Py2/Py3 problem, or a mix thereof. I do not yet know how to fix it, but I can help testing, if that helps.