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

Clarify U-mode deprecation in open() #11646

Merged
merged 5 commits into from
Jan 27, 2019

Conversation

ncoghlan
Copy link
Contributor

The previous wording could be read as saying that universal
newlines mode itself was deprecated, when it's only the 'U'
character in the mode field that should be avoided.

The previous wording could be read as saying that universal
newlines mode itself was deprecated, when it's only the 'U'
character in the mode field that should be avoided.
@ncoghlan
Copy link
Contributor Author

I stumbled across https://softwareengineering.stackexchange.com/questions/298677/why-is-universal-newlines-mode-deprecated-in-python today and realised that the poster's confusion was completely understandable given the way this deprecation was expressed.

@csabella
Copy link
Contributor

Too bad this doesn't link to the place in the text where *newline* is defined. I had to use search to find what the newline argument allowed.

@@ -1004,7 +1004,7 @@ are always available. They are listed here in alphabetical order.
``'b'`` binary mode
``'t'`` text mode (default)
``'+'`` open a disk file for updating (reading and writing)
``'U'`` :term:`universal newlines` mode (deprecated)
``'U'`` equivalent to ``newline=None`` (deprecated, use *newline* option)
Copy link
Contributor

Choose a reason for hiding this comment

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

For me is a good improved. How say @csabella, it would be great have a link to newline definition

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it would be clearer to put :deprecated: before the rest of the text

``'U'``   :deprecated: Use ``newline`` option instead. Equivalent to ``newline=None``

Having a link as suggested by @csabella would be great.

Copy link
Contributor

@willingc willingc left a comment

Choose a reason for hiding this comment

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

This would probably be a bit clearer by putting the deprecation at the start of the line. Thanks.

@@ -1004,7 +1004,7 @@ are always available. They are listed here in alphabetical order.
``'b'`` binary mode
``'t'`` text mode (default)
``'+'`` open a disk file for updating (reading and writing)
``'U'`` :term:`universal newlines` mode (deprecated)
``'U'`` equivalent to ``newline=None`` (deprecated, use *newline* option)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it would be clearer to put :deprecated: before the rest of the text

``'U'``   :deprecated: Use ``newline`` option instead. Equivalent to ``newline=None``

Having a link as suggested by @csabella would be great.

- add cross-reference to newline parameter description
- move deprecation warning to the start of the paragraph
- explain why the mode is deprecated (i.e. it's the default for
  test mode now,  so specifying it explicitly is redundant)
@ncoghlan
Copy link
Contributor Author

I'm not sure bold mark-up inside a cross-reference actually works correctly, so I'm going to pull the branch locally and check that it actually works the way I want rather than continuing solely in the browser.

I couldn't get the longer entry to look any good inside the table, so
I moved it out to a separate paragraph after the description of the
actually useful file modes.
@ncoghlan
Copy link
Contributor Author

After rendering the docs locally, I came to the conclusion that there simply wasn't room inside the table to explain why the 'U' mode option still existed, even though it didn't actually do anything (it's solely there to support cross-platform Py2/3 code that isn't using codecs.open or io.open).

So I moved it down into its own paragraph after the explanation of the actually useful mode characters - that way the info is still there if someone is trying to understand existing code that uses it, but folks writing new code shouldn't ever need to care about it.

Copy link
Contributor

@willingc willingc left a comment

Choose a reason for hiding this comment

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

Nice! Thanks @ncoghlan

@miss-islington
Copy link
Contributor

Thanks @ncoghlan for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 27, 2019
The previous wording could be read as saying that universal
newlines mode itself was deprecated, when it's only the 'U'
character in the mode field that should be avoided.

The update also moves the description of the 'U' mode character
out of the mode table, as the longer explanation was overly
intrusive as a table entry and overshadowed the actually useful
mode characters.
(cherry picked from commit 3171df3)

Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
@bedevere-bot
Copy link

GH-11687 is a backport of this pull request to the 3.7 branch.

miss-islington added a commit that referenced this pull request Jan 27, 2019
The previous wording could be read as saying that universal
newlines mode itself was deprecated, when it's only the 'U'
character in the mode field that should be avoided.

The update also moves the description of the 'U' mode character
out of the mode table, as the longer explanation was overly
intrusive as a table entry and overshadowed the actually useful
mode characters.
(cherry picked from commit 3171df3)

Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
@gvanrossum gvanrossum deleted the ncoghlan-clarify-U-mode-deprecation branch February 1, 2019 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants