src/future/moves/_dummy_thread.py | 2 +- src/future/standard_library/__init__.py | 2 +- src/future/utils/__init__.py | 3 +++ src/past/types/oldstr.py | 2 +- tests/test_future/test_builtins.py | 9 ++++++++- tests/test_future/test_standard_library.py | 9 ++++++++- tests/test_future/test_urllib2.py | 6 +----- tests/test_future/test_urllib_toplevel.py | 2 -- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/future/moves/_dummy_thread.py b/src/future/moves/_dummy_thread.py index 688d249..cc2fc89 100644 --- a/src/future/moves/_dummy_thread.py +++ b/src/future/moves/_dummy_thread.py @@ -2,7 +2,7 @@ from __future__ import absolute_import from future.utils import PY3 if PY3: - from _dummy_thread import * + from _thread import * else: __future_module__ = True from dummy_thread import * diff --git a/src/future/standard_library/__init__.py b/src/future/standard_library/__init__.py index cff02f9..3e8da8a 100644 --- a/src/future/standard_library/__init__.py +++ b/src/future/standard_library/__init__.py @@ -125,7 +125,7 @@ RENAMES = { # 'Tkinter': 'tkinter', '_winreg': 'winreg', 'thread': '_thread', - 'dummy_thread': '_dummy_thread', + 'dummy_thread': '_thread', # 'anydbm': 'dbm', # causes infinite import loop # 'whichdb': 'dbm', # causes infinite import loop # anydbm and whichdb are handled by fix_imports2 diff --git a/src/future/utils/__init__.py b/src/future/utils/__init__.py index 46bd96d..1b5eeea 100644 --- a/src/future/utils/__init__.py +++ b/src/future/utils/__init__.py @@ -61,6 +61,9 @@ PY3 = sys.version_info[0] >= 3 PY34_PLUS = sys.version_info[0:2] >= (3, 4) PY35_PLUS = sys.version_info[0:2] >= (3, 5) PY36_PLUS = sys.version_info[0:2] >= (3, 6) +PY37_PLUS = sys.version_info[0:2] >= (3, 7) +PY38_PLUS = sys.version_info[0:2] >= (3, 8) +PY39_PLUS = sys.version_info[0:2] >= (3, 9) PY2 = sys.version_info[0] == 2 PY26 = sys.version_info[0:2] == (2, 6) PY27 = sys.version_info[0:2] == (2, 7) diff --git a/src/past/types/oldstr.py b/src/past/types/oldstr.py index a477d88..5a0e378 100644 --- a/src/past/types/oldstr.py +++ b/src/past/types/oldstr.py @@ -20,7 +20,7 @@ class BaseOldStr(type): def unescape(s): - """ + r""" Interprets strings with escape sequences Example: diff --git a/tests/test_future/test_builtins.py b/tests/test_future/test_builtins.py index ca07b9e..d77201a 100644 --- a/tests/test_future/test_builtins.py +++ b/tests/test_future/test_builtins.py @@ -1305,7 +1305,14 @@ class BuiltinTest(unittest.TestCase): 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) + # + # Changed in version 3.8: For int operands, the three-argument form of + # pow now allows the second argument to be negative, permitting + # computation of modular inverses. + if sys.version_info < (3, 8): + self.assertRaises((TypeError, ValueError), pow, -1, -2, 3) + else: + self.assertEqual(pow(-1, -2, 3), 1) self.assertRaises(ValueError, pow, 1, 2, 0) self.assertRaises(TypeError, pow) diff --git a/tests/test_future/test_standard_library.py b/tests/test_future/test_standard_library.py index 3ac5d2d..65fd26c 100644 --- a/tests/test_future/test_standard_library.py +++ b/tests/test_future/test_standard_library.py @@ -340,6 +340,10 @@ class TestStandardLibraryReorganization(CodeHandler): # pprint(r.read().decode('utf-8')) self.assertTrue(True) + @unittest.skipIf( + os.environ.get("NO_INTERNET") is not None, + "Requires internet connection", + ) def test_moves_urllib_request_http(self): """ This site (python-future.org) uses plain http (as of 2014-09-23). @@ -351,6 +355,10 @@ class TestStandardLibraryReorganization(CodeHandler): data = r.read() self.assertTrue(b'' in data) + @unittest.skipIf( + os.environ.get("NO_INTERNET") is not None, + "Requires internet connection", + ) def test_urllib_request_http(self): """ This site (python-future.org) uses plain http (as of 2014-09-23). @@ -422,7 +430,6 @@ class TestStandardLibraryReorganization(CodeHandler): def test_underscore_prefixed_modules(self): import _thread - import _dummy_thread import _markupbase self.assertTrue(True) diff --git a/tests/test_future/test_urllib2.py b/tests/test_future/test_urllib2.py index 2d69dad..e7fb4dd 100644 --- a/tests/test_future/test_urllib2.py +++ b/tests/test_future/test_urllib2.py @@ -691,10 +691,6 @@ class HandlerTests(unittest.TestCase): 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", @@ -713,7 +709,7 @@ class HandlerTests(unittest.TestCase): ["foo", "bar"], "", None), ("ftp://localhost/baz.gif;type=a", "localhost", ftplib.FTP_PORT, "", "", "A", - [], "baz.gif", guessed_mime), + [], "baz.gif", None), # XXX really this should guess image/gif ]: req = Request(url) req.timeout = None diff --git a/tests/test_future/test_urllib_toplevel.py b/tests/test_future/test_urllib_toplevel.py index 11e7720..25f4ca8 100644 --- a/tests/test_future/test_urllib_toplevel.py +++ b/tests/test_future/test_urllib_toplevel.py @@ -781,8 +781,6 @@ class UnquotingTests(unittest.TestCase): "%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'')) def test_unquoting_badpercent(self): # Test unquoting on bad percent-escapes