Skip to content

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

Open
guoci wants to merge 4 commits intopython:mainfrom
guoci:doc_newline_decoders
Open

bpo-46209: add documentation for decoding newlines in the io module#30308
guoci wants to merge 4 commits intopython:mainfrom
guoci:doc_newline_decoders

Conversation

@guoci
Copy link
Copy Markdown
Contributor

@guoci guoci commented Dec 30, 2021

@bedevere-bot bedevere-bot added the docs Documentation in the Doc dir label Dec 30, 2021
Comment thread Doc/library/io.rst Outdated
Comment thread Doc/library/io.rst
Comment thread Doc/library/io.rst Outdated
.. attribute:: newlines

a tuple of types of newlines encountered, or the newline if only
one type of newline is found.
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread Doc/library/io.rst Outdated
Comment thread Doc/library/io.rst Outdated
@guoci
Copy link
Copy Markdown
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
Copy Markdown
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.

@guoci guoci force-pushed the doc_newline_decoders branch from 0081b76 to 2c73105 Compare October 31, 2025 15:01
Comment thread Doc/library/io.rst Outdated
@guoci
Copy link
Copy Markdown
Contributor Author

guoci commented Nov 14, 2025

@merwok is that ok now?

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting change review docs Documentation in the Doc dir stale Stale PR or inactive for long period of time.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

9 participants