This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ConfigParser uses wrong newline on Windows
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: lukasz.langa Nosy List: lukasz.langa, mrblabla
Priority: normal Keywords:

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:22adminsetgithub: 57399
2012-01-23 17:17:36lukasz.langasetstatus: open -> closed
resolution: works for me
messages: + msg151829

stage: resolved
2011-10-17 15:36:51eric.araujosetassignee: lukasz.langa
versions: + Python 3.3, - Python 2.6
nosy: + lukasz.langa
components: + Library (Lib), - None
2011-10-16 17:47:51mrblablacreate