Eryk Sun <eryk...@gmail.com> added the comment:

> like those returned by the open() function. Their parameters are 
> chosen as follows..."

The `newline` argument for sys.std* isn't documented, but it should be. It 
happens to be newline='\n' on every platform except Windows.

> its newlines attribute is set to None

The `newlines` attribute is based on the `newlines` attribute of the 
incremental decoder. It defaults to None if the decoder lacks this attribute. 
AFAIK, only the universal newlines decoder, io.IncrementalNewlineDecoder, 
implements this attribute. If it's not None, the value is a string or tuple 
that tracks the types of newlines that have been seen thus far. For example:

    >>> fdr, fdw = os.pipe()
    >>> f = open(fdr, 'r', newline=None, closefd=False)
    >>> os.write(fdw, b'a\r\n')
    3
    >>> f.readline()
    'a\n'
    >>> f.newlines
    '\r\n'
    >>> os.write(fdw, b'a\n')
    2
    >>> f.readline()
    'a\n'
    >>> f.newlines
    ('\n', '\r\n')

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45617>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to