classification
Title: Default newlines of io.TextIOWrapper
Type: Stage:
Components: Documentation Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: asvetlov, chris.jerdonek, docs@python, ishimoto, pitrou, r.david.murray
Priority: normal Keywords:

Created on 2012-08-04 15:59 by ishimoto, last changed 2012-08-13 12:19 by chris.jerdonek.

Messages (6)
msg167413 - (view) Author: Atsuo Ishimoto (ishimoto) * Date: 2012-08-04 15:59
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.
msg167451 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-08-04 22:26
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.
msg167820 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-08-09 19:11
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
msg167821 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-08-09 19:22
I don't think the C version does, though.
msg168084 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-08-13 12:13
It doesn't.
_io can be fixed to directly support os.linesep, but I doubt if anybody really need it.
msg168086 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-08-13 12:19
I think it can be useful for testing reasons (e.g. testing that os.linesep is respected by certain code).
History
Date User Action Args
2012-08-13 12:19:13chris.jerdoneksetmessages: + msg168086
2012-08-13 12:13:04asvetlovsetnosy: + asvetlov
messages: + msg168084
2012-08-09 19:22:21r.david.murraysetnosy: + pitrou
messages: + msg167821
2012-08-09 19:11:17chris.jerdoneksetnosy: + chris.jerdonek
messages: + msg167820
2012-08-04 22:26:50r.david.murraysetnosy: + r.david.murray
messages: + msg167451
2012-08-04 15:59:58ishimotocreate