Issue 13190: ConfigParser uses wrong newline on Windows (original) (raw)

Issue13190

Created on 2011-10-16 17:47 by mrblabla, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg145632 - (view) Author: Mr Bla Bla (mrblabla) Date: 2011-10-16 17:47
ConfigParser writes data to the config file using hard-coded newline: '\n'. This newline is not suitable for Windows. Therefore, the config file isn't readable in Notepad.exe. os.linesep should be used instead.
msg151829 - (view) Author: Ɓukasz Langa (lukasz.langa) * (Python committer) Date: 2012-01-23 17:17
That is indeed the behaviour. Citing the tutorial: "Python on Windows makes a distinction between text and binary files; the end-of-line characters in text files are automatically altered slightly when data is read or written." When you're opening the file in binary mode, \n characters are not altered. Opening a file that way specifies programmer intent and I don't think we should force os.linesep in that case.
History
Date User Action Args
2022-04-11 14:57:22 admin set github: 57399
2012-01-23 17:17:36 lukasz.langa set status: open -> closedresolution: works for memessages: + stage: resolved
2011-10-17 15:36:51 eric.araujo set assignee: lukasz.langaversions: + Python 3.3, - Python 2.6nosy: + lukasz.langacomponents: + Library (Lib), - None
2011-10-16 17:47:51 mrblabla create