[New-bugs-announce] [issue43337] export the set newline value on TextIOBase/TextIOWrapper

Christoph Anton Mitterer report at bugs.python.org
Sat Feb 27 00:45:28 EST 2021


New submission from Christoph Anton Mitterer <calestyo at 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 <report at bugs.python.org>
<https://bugs.python.org/issue43337>
_______________________________________


More information about the New-bugs-announce mailing list