Bug report #8915

Newline character of Python output is forced to LF only

Added by Tarot Osuji about 11 years ago. Updated over 10 years ago.

Status:Rejected
Priority:Normal
Assignee:-
Category:Python plugins
Affected QGIS version:2.0.1 Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:up/downstream
Crashes QGIS or corrupts data:No Copied to github as #:17591

Description

Execution of following Python code:

f = open(filename, "w")
f.write("FOOBAR\
")
f.close()

is expected to output the file which includes newline character according to platform.
Although I tested the code on Windows version of QGIS, the newline character becomes not CR+LF but LF.

This behaviour influences batch file generation like Processing plug-in.
The batch file which includes multibyte character & LF newline doesn't work on some
localized version of Windows (e.g., Japanese).

newline_test.png - The operation difference between newline character (25.8 KB) Tarot Osuji, 2013-10-18 10:23 PM

History

#1 Updated by Alexander Bruy over 10 years ago

  • Resolution set to up/downstream
  • Status changed from Open to Rejected

I suppose this is not a QGIS issue but Python one.

#2 Updated by Tarot Osuji over 10 years ago

No.
If you call the Python bundled with QGIS from the command line, it handles correctly. However, when called from QGIS, it mishandled.
CR character seems to have been removed at all times during the communication between Python and QGIS.

Also available in: Atom PDF