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

U flag deprecated since Python 3.3 and removed in 3.9 #256

Closed
wants to merge 2 commits into from

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Jan 21, 2020

Fedora bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1792948

python-pylibmc fails to build with Python 3.9.0a2.

+ /usr/bin/python3 setup.py build '--executable=/usr/bin/python3 -s'
Traceback (most recent call last):
  File "/builddir/build/BUILD/pylibmc-1.5.1/setup.py", line 98, in <module>
    with open("README.rst", "U", encoding="utf-8") as r:
ValueError: invalid mode: 'U'

See https://docs.python.org/3.9/whatsnew/3.9.html#changes-in-the-python-api

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. In Python 3, the “universal newline” is used by default when a file is open in text mode. The newline parameter of open() controls how universal newlines works.

Use the default "r" for Python 3.3+.

Python 3.9 is in alpha with a full release due in October.


Also, heads up, nose is unmaintained and doesn't work on Python 3.9: nose-devs/nose#1099. You'll need to migrate testing to something new, I'd suggest pytest.

And 3.9-dev is now available on Travis CI.

@hroncok
Copy link

hroncok commented Jan 21, 2020

Alternatively, you can use io.open() on Python 2 to get a more Python3-like open().

@lericson
Copy link
Owner

Interesting. I would probably say that the better solution would be to do a major version release, and break with Python 2.x altogether.

@hugovk
Copy link
Contributor Author

hugovk commented Jan 22, 2020

Even better! I'll create a new PR.

@hugovk
Copy link
Contributor Author

hugovk commented Jan 22, 2020

And I'll remove EOL 3.2-3.4 too.

@lericson
Copy link
Owner

(Also hooray, I outlived nose.)

I think a major version release should include a more thorough cleaning, there is a lot of version testing in the C code.

@hugovk
Copy link
Contributor Author

hugovk commented Jan 22, 2020

Please see PR #258.

@hugovk
Copy link
Contributor Author

hugovk commented Jul 13, 2020

Well this got fixed in 22854a4 so this PR is no longer needed :)

@hugovk hugovk closed this Jul 13, 2020
@hugovk hugovk deleted the fix-open-for-python3.9 branch July 13, 2020 15:16
@lericson
Copy link
Owner

That's right, thanks for noticing!

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.

3 participants