[issue15555] Default newlines of io.TextIOWrapper
New submission from Atsuo Ishimoto: In http://docs.python.org/dev/library/io.html: "if newline is None, any '\n' characters written are translated to the system default line separator, os.linesep. " But os.linesep is not referred at all. On Windows default newline is always '\r\n' on Windows, '\n' otherwise. ---------- assignee: docs@python components: Documentation messages: 167413 nosy: docs@python, ishimoto priority: normal severity: normal status: open title: Default newlines of io.TextIOWrapper _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15555> _______________________________________
R. David Murray added the comment: And that is the value of os.linesep at Python startup. I'm don't think that we really support the mutability of os.linesep, we just don't bother to make it immutable. I'm not sure how this would be documented, since code that does use "os.linesep" is indeed affected by changing it. ---------- nosy: +r.david.murray _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15555> _______________________________________
Chris Jerdonek added the comment: What is the change to the documentation being suggested here? The code does reference os.linesep, so it seems like the documentation is correct, or am I missing something? self._writetranslate = newline != '' self._writenl = newline or os.linesep self._encoder = None http://hg.python.org/cpython/file/20a46c73855f/Lib/_pyio.py#l1501 ---------- nosy: +cjerdonek _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15555> _______________________________________
R. David Murray added the comment: I don't think the C version does, though. ---------- nosy: +pitrou _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15555> _______________________________________
Andrew Svetlov added the comment: It doesn't. _io can be fixed to directly support os.linesep, but I doubt if anybody really need it. ---------- nosy: +asvetlov _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15555> _______________________________________
Chris Jerdonek added the comment: I think it can be useful for testing reasons (e.g. testing that os.linesep is respected by certain code). ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15555> _______________________________________
participants (4)
-
Andrew Svetlov
-
Atsuo Ishimoto
-
Chris Jerdonek
-
R. David Murray