lericson / pylibmc

A Python wrapper around the libmemcached interface from TangentOrg.
http://sendapatch.se/projects/pylibmc/
BSD 3-Clause "New" or "Revised" License
478 stars 136 forks source link

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

Closed hugovk closed 3 years ago

hugovk commented 4 years ago

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: https://github.com/nose-devs/nose/issues/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 commented 4 years ago

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

lericson commented 4 years ago

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 commented 4 years ago

Even better! I'll create a new PR.

hugovk commented 4 years ago

And I'll remove EOL 3.2-3.4 too.

lericson commented 4 years ago

(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 commented 4 years ago

Please see PR https://github.com/lericson/pylibmc/pull/258.

hugovk commented 3 years ago

Well this got fixed in https://github.com/lericson/pylibmc/commit/22854a4ba8f7e926099219c107104723089bcad8 so this PR is no longer needed :)

lericson commented 3 years ago

That's right, thanks for noticing!