Skip to content

bpo-46209: add documentation for decoding newlines in the io module #30308

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

guoci
Copy link
Contributor

@guoci guoci commented Dec 30, 2021

@bedevere-bot bedevere-bot added the docs Documentation in the Doc dir label Dec 30, 2021
.. attribute:: newlines

a tuple of types of newlines encountered, or the newline if only
one type of newline is found.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The types are not clear here. Are you saying this is a tuple of strings or one string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type is either a string or tuple of strings

cpython/Lib/_pyio.py

Lines 1971 to 1980 in e18d815

def newlines(self):
return (None,
"\n",
"\r",
("\r", "\n"),
"\r\n",
("\n", "\r\n"),
("\r", "\r\n"),
("\r", "\n", "\r\n")
)[self.seennl]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok! I wouldn’t say types of newlines, unless that phrase is used elsewhere in the docs, it could be confusing.

Copy link
Contributor Author

@guoci guoci Dec 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about changing to representations of newlines?

records the types of newlines encountered. When used with

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds a bit abstract to me. These are newlines, meaning strings.
Isn’t there an existing phrase in io docs or dosctrings that can be reused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find any in the io docs, The docstring of that class says types of newlines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth just giving some examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listed all the possible values.

Co-authored-by: Éric <merwok@netwok.org>
guoci and others added 3 commits December 31, 2021 13:55
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Éric <merwok@netwok.org>
@guoci
Copy link
Contributor Author

guoci commented Jan 1, 2022

@merwok Also, may I request you to look at #30276 too? It is very related to this.

Copy link
Contributor

@MaxwellDupre MaxwellDupre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs complied on my machine. Looks ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes docs Documentation in the Doc dir
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

8 participants