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

bpo-37330: open() no longer accept 'U' in file mode #16959

Merged
merged 3 commits into from
Oct 28, 2019
Merged

bpo-37330: open() no longer accept 'U' in file mode #16959

merged 3 commits into from
Oct 28, 2019

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 27, 2019

open(), io.open(), codecs.open() and fileinput.FileInput no longer
accept "U" ("universal newline") in the file mode. This flag was
deprecated since Python 3.3.

test_fileinput: add tests for 'rU' and 'U' modes

Run make regen-all.

https://bugs.python.org/issue37330

open(), io.open(), codecs.open() and fileinput.FileInput no longer
accept "U" ("universal newline") in the file mode. This flag was
deprecated since Python 3.3.

test_fileinput: add tests for 'rU' and 'U' modes

Run make regen-all.
@vstinner
Copy link
Member Author

This is the rebased PR #14204 that I failed to reopen. docutils and Sphinx were updated: they no longer use open("U").

@serhiy-storchaka: You approved PR #14204, would you mind to approve this PR as well?

Copy link
Member

@tirkarthi tirkarthi left a comment

Choose a reason for hiding this comment

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

LGTM. It seems test_pty failure is tracked with https://bugs.python.org/issue38547. Thanks Victor.

@vstinner
Copy link
Member Author

@serhiy-storchaka: I added more tests, does it look good to you now?

# "U" mode has been removed in Python 3.9
for mode in ("U", "rU", "r+U"):
with self.assertRaises(ValueError) as cm:
codecs.open(support.TESTFN, mode)
Copy link
Member

Choose a reason for hiding this comment

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

Pass an encoding.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooooh, the codecs module remains a mystery to me :-) Ok, I added an encoding and I added tests for "rt" mode.

@vstinner
Copy link
Member Author

@serhiy-storchaka: Sorry, I misunderstood the codecs module for "rt" mode. Adding an encoding was the fix :-) I added more tests for this mode as well.

@vstinner vstinner merged commit e471e72 into python:master Oct 28, 2019
@vstinner vstinner deleted the remove_open_universal2 branch October 28, 2019 14:40
jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this pull request Dec 5, 2019
open(), io.open(), codecs.open() and fileinput.FileInput no longer
accept "U" ("universal newline") in the file mode. This flag was
deprecated since Python 3.3.
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Jan 31, 2020
open(), io.open(), codecs.open() and fileinput.FileInput no longer
accept "U" ("universal newline") in the file mode. This flag was
deprecated since Python 3.3.
vstinner added a commit that referenced this pull request Mar 4, 2020
GH-16959)" (GH-18767)

This reverts commit e471e72.

The mode will be removed from Python 3.10.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants