Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export the set newline value on TextIOBase/TextIOWrapper #87503

Open
calestyo mannequin opened this issue Feb 27, 2021 · 1 comment
Open

export the set newline value on TextIOBase/TextIOWrapper #87503

calestyo mannequin opened this issue Feb 27, 2021 · 1 comment
Labels
topic-IO type-feature A feature request or enhancement

Comments

@calestyo
Copy link
Mannequin

calestyo mannequin commented Feb 27, 2021

BPO 43337
Nosy @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-02-27.05:45:28.919>
labels = ['type-feature', 'expert-IO']
title = 'export the set newline value on TextIOBase/TextIOWrapper'
updated_at = <Date 2021-03-05.21:03:13.665>
user = 'https://bugs.python.org/calestyo'

bugs.python.org fields:

activity = <Date 2021-03-05.21:03:13.665>
actor = 'terry.reedy'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['IO']
creation = <Date 2021-02-27.05:45:28.919>
creator = 'calestyo'
dependencies = []
files = []
hgrepos = []
issue_num = 43337
keywords = []
message_count = 1.0
messages = ['387767']
nosy_count = 2.0
nosy_names = ['benjamin.peterson', 'calestyo']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue43337'
versions = []

@calestyo
Copy link
Mannequin Author

calestyo mannequin commented Feb 27, 2021

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.

@calestyo calestyo mannequin added topic-IO type-feature A feature request or enhancement labels Feb 27, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-IO type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

0 participants