Skip to content

Add support Python 3.9 #578

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

Merged
merged 7 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ matrix:
env: TOXENV=py36
- python: 3.7
env: TOXENV=py37
dist: xenial # required for Python 3.7 (travis-ci/travis-ci#9069)
sudo: required # required for Python 3.7 (travis-ci/travis-ci#9069)
dist: xenial
- python: 3.8
env: TOXENV=py38
dist: xenial
- python: 3.9
env: TOXENV=py39
dist: bionic

install:
- pip install typing==3.7.4.1 # required for Python 3.3
Expand Down
7 changes: 4 additions & 3 deletions src/future/backports/xmlrpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@
from future.builtins import bytes, dict, int, range, str

import base64
# Py2.7 compatibility hack
base64.encodebytes = base64.encodestring
base64.decodebytes = base64.decodestring
import sys
if sys.version_info < (3, 9):
# Py2.7 compatibility hack
base64.encodebytes = base64.encodestring
base64.decodebytes = base64.decodestring
import time
from datetime import datetime
from future.backports.http import client as http_client
Expand Down
5 changes: 4 additions & 1 deletion src/future/moves/_dummy_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from future.utils import PY3

if PY3:
from _dummy_thread import *
try:
from _dummy_thread import *
except ImportError:
from _thread import *
else:
__future_module__ = True
from dummy_thread import *
2 changes: 1 addition & 1 deletion src/future/standard_library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
# 'Tkinter': 'tkinter',
'_winreg': 'winreg',
'thread': '_thread',
'dummy_thread': '_dummy_thread',
'dummy_thread': '_dummy_thread' if sys.version_info < (3, 9) else '_thread',
# 'anydbm': 'dbm', # causes infinite import loop
# 'whichdb': 'dbm', # causes infinite import loop
# anydbm and whichdb are handled by fix_imports2
Expand Down
3 changes: 2 additions & 1 deletion tests/test_future/test_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,8 @@ def test_pow(self):
self.assertAlmostEqual(pow(-1, 1/3), 0.5 + 0.8660254037844386j)

# Raises TypeError in Python < v3.5, ValueError in v3.5:
self.assertRaises((TypeError, ValueError), pow, -1, -2, 3)
if sys.version_info < (3, 8):
self.assertRaises((TypeError, ValueError), pow, -1, -2, 3)
self.assertRaises(ValueError, pow, 1, 2, 0)

self.assertRaises(TypeError, pow)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_future/test_standard_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ def test_urllib_imports_install_hooks(self):

def test_underscore_prefixed_modules(self):
import _thread
import _dummy_thread
if sys.version_info < (3, 9):
import _dummy_thread
import _markupbase
self.assertTrue(True)

Expand Down
9 changes: 4 additions & 5 deletions tests/test_future/test_urllib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,6 @@ def connect_ftp(self, user, passwd, host, port, dirs,
h = NullFTPHandler(data)
h.parent = MockOpener()

# MIME guessing works in Python 3.8!
guessed_mime = None
if sys.hexversion >= 0x03080000:
guessed_mime = "image/gif"
for url, host, port, user, passwd, type_, dirs, filename, mimetype in [
("ftp://localhost/foo/bar/baz.html",
"localhost", ftplib.FTP_PORT, "", "", "I",
Expand All @@ -713,7 +709,10 @@ def connect_ftp(self, user, passwd, host, port, dirs,
["foo", "bar"], "", None),
("ftp://localhost/baz.gif;type=a",
"localhost", ftplib.FTP_PORT, "", "", "A",
[], "baz.gif", guessed_mime),
[], "baz.gif", None),
("ftp://localhost/baz.gif",
"localhost", ftplib.FTP_PORT, "", "", "I",
[], "baz.gif", "image/gif"),
]:
req = Request(url)
req.timeout = None
Expand Down
9 changes: 5 additions & 4 deletions tests/test_future/test_urllib_toplevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def setUp(self):
finally:
f.close()
self.pathname = support.TESTFN
self.returned_obj = urlopen("file:%s" % self.pathname)
self.returned_obj = urlopen("file:%s" % urllib_parse.quote(self.pathname))

def tearDown(self):
"""Shut down the open object"""
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_info(self):
self.assertIsInstance(self.returned_obj.info(), email_message.Message)

def test_geturl(self):
self.assertEqual(self.returned_obj.geturl(), self.pathname)
self.assertEqual(self.returned_obj.geturl(), urllib_parse.quote(self.pathname))

def test_getcode(self):
self.assertIsNone(self.returned_obj.getcode())
Expand Down Expand Up @@ -781,8 +781,9 @@ def test_unquoting(self):
"%s" % result)
self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, None)
self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, ())
with support.check_warnings(('', BytesWarning), quiet=True):
self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, bytes(b''))
if sys.version_info < (3, 9):
with support.check_warnings(('', BytesWarning), quiet=True):
self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, bytes(b''))

def test_unquoting_badpercent(self):
# Test unquoting on bad percent-escapes
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{26,27,33,34,35,36,37},
py{26,27,33,34,35,36,37,38,39},
docs

[testenv]
Expand Down