New submission from Christoph Anton Mitterer <cales...@scientia.org>:

Hey.

It seems there is no way to determine the newline value (None, '', \n, \r, 
\r\n) of a given text stream.
.newlines rather gives the newlines that have been encountered so far.


Just like .encoding and .errors this would be quite useful for anything that 
gets a stream and operates on it, possibly needing to know which newlines it 
will see when reading from the stream.

One example would be, after line = stream.readline(4096+n) one want's to know 
whether actually a full line of 4096 characters has been read.
Putting aside newline="", for simplicity here, n already depends on whether 
newline was None, \n, \r or \r\n, as would any check like line.endswith(foo).


Maybe some attribute, that indicates the most recently read newline in 
newline="" mode, would be helpful, too.


Cheers,
Chris.

----------
components: IO
messages: 387767
nosy: calestyo
priority: normal
severity: normal
status: open
title: export the set newline value on TextIOBase/TextIOWrapper
type: enhancement

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

Reply via email to