summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--gnu/local.mk3
-rw-r--r--gnu/packages/patches/python-3-fix-tests.patch194
-rw-r--r--gnu/packages/patches/python-3.8-fix-tests.patch42
-rw-r--r--gnu/packages/python.scm61
4 files changed, 171 insertions, 129 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index b4ffbd3a81..a7e60a43d7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -19,7 +19,7 @@
 # Copyright © 2018 Amirouche Boubekki <amirouche@hypermove.net>
 # Copyright © 2018, 2019, 2020 Oleg Pykhalov <go.wigust@gmail.com>
 # Copyright © 2018 Stefan Stefanović <stefanx2ovic@gmail.com>
-# Copyright © 2018, 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+# Copyright © 2018, 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 # Copyright © 2019, 2020 Guillaume Le Vaillant <glv@posteo.net>
 # Copyright © 2019, 2020 John Soo <jsoo1@asu.edu>
 # Copyright © 2019 Jonathan Brielmaier <jonathan.brielmaier@web.de>
@@ -1505,7 +1505,6 @@ dist_patch_DATA =						\
   %D%/packages/patches/python-3-deterministic-build-info.patch	\
   %D%/packages/patches/python-3-search-paths.patch		\
   %D%/packages/patches/python-3-fix-tests.patch			\
-  %D%/packages/patches/python-3.8-fix-tests.patch		\
   %D%/packages/patches/python-3-hurd-configure.patch		\
   %D%/packages/patches/python-CVE-2018-14647.patch		\
   %D%/packages/patches/python-aionotify-0.2.0-py3.8.patch	\
diff --git a/gnu/packages/patches/python-3-fix-tests.patch b/gnu/packages/patches/python-3-fix-tests.patch
index e13790bd41..b44e743c71 100644
--- a/gnu/packages/patches/python-3-fix-tests.patch
+++ b/gnu/packages/patches/python-3-fix-tests.patch
@@ -1,10 +1,39 @@
-See the discussion about the issues fixed here at:
-http://bugs.python.org/issue20868 .
+From f0698133e7d6c353a3e6ae0fc62e57ba558a9bc0 Mon Sep 17 00:00:00 2001
+From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
+Date: Wed, 28 Oct 2020 22:55:05 -0400
+Subject: [PATCH] Skip problematic Python 3 tests in Guix.
+
+A subset of the hunks in this patch is tracked upstream at
+https://bugs.python.org/issue38845, which was contributed by Tanguy Le
+Carrour <tanguy@bioneland.org>.
+---
+ Lib/ctypes/test/test_callbacks.py         | 3 +++
+ Lib/ctypes/test/test_find.py              | 1 +
+ Lib/ctypes/test/test_libc.py              | 3 +++
+ Lib/distutils/tests/test_archive_util.py  | 2 ++
+ Lib/distutils/tests/test_sdist.py         | 1 +
+ Lib/test/_test_multiprocessing.py         | 2 ++
+ Lib/test/test_asyncio/test_base_events.py | 2 ++
+ Lib/test/test_generators.py               | 1 +
+ Lib/test/test_pathlib.py                  | 3 +--
+ Lib/test/test_pdb.py                      | 4 ++--
+ Lib/test/test_regrtest.py                 | 2 ++
+ Lib/test/test_resource.py                 | 1 +
+ Lib/test/test_shutil.py                   | 2 ++
+ Lib/test/test_signal.py                   | 4 ++++
+ Lib/test/test_socket.py                   | 8 ++++++++
+ Lib/test/test_spwd.py                     | 6 ++----
+ Lib/test/test_tarfile.py                  | 9 ++++++---
+ Lib/test/test_threading.py                | 3 +++
+ Lib/test/test_unicodedata.py              | 1 +
+ Tools/scripts/run_tests.py                | 2 +-
+ 20 files changed, 48 insertions(+), 12 deletions(-)
 
 diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
+index d8e9c5a760..94fc5929c9 100644
 --- a/Lib/ctypes/test/test_callbacks.py
 +++ b/Lib/ctypes/test/test_callbacks.py
-@@ -3,6 +3,7 @@ import unittest
+@@ -5,6 +5,7 @@ from test import support
  from ctypes import *
  from ctypes.test import need_symbol
  import _ctypes_test
@@ -12,7 +41,7 @@ diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.
  
  class Callbacks(unittest.TestCase):
      functype = CFUNCTYPE
-@@ -176,6 +177,8 @@ class SampleCallbacksTestCase(unittest.TestCase):
+@@ -178,6 +179,8 @@ class SampleCallbacksTestCase(unittest.TestCase):
  
          self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)
  
@@ -21,7 +50,20 @@ diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.
      def test_issue_8959_a(self):
          from ctypes.util import find_library
          libc_path = find_library("c")
+diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
+index 92ac1840ad..c8eb75dedd 100644
+--- a/Lib/ctypes/test/test_find.py
++++ b/Lib/ctypes/test/test_find.py
+@@ -116,6 +116,7 @@ class FindLibraryLinux(unittest.TestCase):
+         with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
+             self.assertNotEqual(find_library('c'), None)
+ 
++    @unittest.skipIf(True, "ldconfig is not used on Guix")
+     def test_find_library_with_ld(self):
+         with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
+              unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
 diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
+index 56285b5ff8..c088ab3db8 100644
 --- a/Lib/ctypes/test/test_libc.py
 +++ b/Lib/ctypes/test/test_libc.py
 @@ -2,6 +2,7 @@ import unittest
@@ -42,6 +84,7 @@ diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
          comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char))
          lib.my_qsort.argtypes = c_void_p, c_size_t, c_size_t, comparefunc
 diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py
+index e9aad0e40f..8bbaa51ee5 100644
 --- a/Lib/distutils/tests/test_archive_util.py
 +++ b/Lib/distutils/tests/test_archive_util.py
 @@ -333,6 +333,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
@@ -61,6 +104,7 @@ diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test
          tmpdir =  self._create_files()
          base_name = os.path.join(self.mkdtemp(), 'archive')
 diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
+index 23db126959..6e2329df7d 100644
 --- a/Lib/distutils/tests/test_sdist.py
 +++ b/Lib/distutils/tests/test_sdist.py
 @@ -443,6 +443,7 @@ class SDistTestCase(BasePyPIRCCommandTestCase):
@@ -72,9 +116,10 @@ diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.
          # now building a sdist
          dist, cmd = self.get_cmd()
 diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
+index e47905c863..31a5a9c308 100644
 --- a/Lib/test/_test_multiprocessing.py
 +++ b/Lib/test/_test_multiprocessing.py
-@@ -1473,6 +1473,7 @@ class _TestCondition(BaseTestCase):
+@@ -1577,6 +1577,7 @@ class _TestCondition(BaseTestCase):
          if pid is not None:
              os.kill(pid, signal.SIGINT)
  
@@ -82,10 +127,19 @@ diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.
      def test_wait_result(self):
          if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
              pid = os.getpid()
+@@ -3905,6 +3906,7 @@ class _TestSharedMemory(BaseTestCase):
+         sms.close()
+ 
+     @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
++    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+     def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
+         # bpo-36368: protect SharedMemoryManager server process from
+         # KeyboardInterrupt signals.
 diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
+index 533d5cc7f5..c4f860cc3b 100644
 --- a/Lib/test/test_asyncio/test_base_events.py
 +++ b/Lib/test/test_asyncio/test_base_events.py
-@@ -1323,6 +1323,8 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
+@@ -1341,6 +1341,8 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
          self._test_create_connection_ip_addr(m_socket, False)
  
      @patch_socket
@@ -95,9 +149,10 @@ diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/t
          m_socket.getaddrinfo = socket.getaddrinfo
          sock = m_socket.socket.return_value
 diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
+index 3bf1522808..04bac8a7db 100644
 --- a/Lib/test/test_generators.py
 +++ b/Lib/test/test_generators.py
-@@ -34,6 +34,7 @@ class SignalAndYieldFromTest(unittest.TestCase):
+@@ -33,6 +33,7 @@ class SignalAndYieldFromTest(unittest.TestCase):
          else:
              return "FAILED"
  
@@ -105,30 +160,11 @@ diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
      def test_raise_and_yield_from(self):
          gen = self.generator1()
          gen.send(None)
-diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py
---- a/Lib/test/test_normalization.py
-+++ b/Lib/test/test_normalization.py
-@@ -2,6 +2,7 @@ from test.support import open_urlresource
- import unittest
- 
- from http.client import HTTPException
-+from urllib.error import URLError
- import sys
- from unicodedata import normalize, unidata_version
- 
-@@ -43,6 +44,8 @@ class NormalizationTest(unittest.TestCase):
-         except PermissionError:
-             self.skipTest(f"Permission error when downloading {TESTDATAURL} "
-                           f"into the test data directory")
-+        except URLError:
-+            self.skipTest("DNS lookups are not enabled.")
-         except (OSError, HTTPException):
-             self.fail(f"Could not retrieve {TESTDATAURL}")
- 
 diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
+index 3da35710b9..5404f9193d 100644
 --- a/Lib/test/test_pathlib.py
 +++ b/Lib/test/test_pathlib.py
-@@ -2134,8 +2134,7 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
+@@ -2408,8 +2408,7 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
          self.assertEqual(given, expect)
          self.assertEqual(set(p.rglob("FILEd*")), set())
  
@@ -139,9 +175,10 @@ diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
          P = self.cls
          support.import_module('pwd')
 diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
+index 8016f81e5a..10190486b4 100644
 --- a/Lib/test/test_pdb.py
 +++ b/Lib/test/test_pdb.py
-@@ -1150,11 +1150,11 @@ def test_pdb_issue_20766():
+@@ -1219,11 +1219,11 @@ def test_pdb_issue_20766():
      > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
      -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
      (Pdb) continue
@@ -156,9 +193,10 @@ diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
  
  
 diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
+index a77638b10a..2069b349a8 100644
 --- a/Lib/test/test_regrtest.py
 +++ b/Lib/test/test_regrtest.py
-@@ -762,6 +762,7 @@ class ArgsTestCase(BaseTestCase):
+@@ -811,6 +811,7 @@ class ArgsTestCase(BaseTestCase):
          output = self.run_tests('--fromfile', filename)
          self.check_executed_tests(output, tests)
  
@@ -166,7 +204,7 @@ diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
      def test_interrupted(self):
          code = TEST_INTERRUPTED
          test = self.create_test('sigint', code=code)
-@@ -779,6 +780,7 @@ class ArgsTestCase(BaseTestCase):
+@@ -828,6 +829,7 @@ class ArgsTestCase(BaseTestCase):
                   % (self.TESTNAME_REGEX, len(tests)))
          self.check_line(output, regex)
  
@@ -175,9 +213,10 @@ diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
          # Issue #25373: test --slowest with an interrupted test
          code = TEST_INTERRUPTED
 diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
+index e5ece5284c..5299e54507 100644
 --- a/Lib/test/test_resource.py
 +++ b/Lib/test/test_resource.py
-@@ -145,6 +145,7 @@ class ResourceTest(unittest.TestCase):
+@@ -148,6 +148,7 @@ class ResourceTest(unittest.TestCase):
  
      @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
      @support.requires_linux_version(2, 6, 36)
@@ -186,37 +225,75 @@ diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
          self.assertRaises(TypeError, resource.prlimit)
          self.assertRaises(ProcessLookupError, resource.prlimit,
 diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
+index e19af64be0..1b893df6fa 100644
 --- a/Lib/test/test_shutil.py
 +++ b/Lib/test/test_shutil.py
-@@ -1143,6 +1143,7 @@ class TestShutil(unittest.TestCase):
+@@ -1427,6 +1427,7 @@ class TestArchives(BaseTest, unittest.TestCase):
+         base_name = os.path.join(tmpdir, 'archive')
          self.assertRaises(ValueError, make_archive, base_name, 'xxx')
  
-     @support.requires_zlib
-+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
++    @unittest.skipIf(True, "The Guix build container has no root user")
+     @support.requires_zlib()
      def test_make_archive_owner_group(self):
          # testing make_archive with owner and group, with various combinations
-         # this works even if there's not gid/uid support
-@@ -1171,6 +1172,7 @@ class TestShutil(unittest.TestCase):
+@@ -1455,6 +1456,7 @@ class TestArchives(BaseTest, unittest.TestCase):
+         self.assertTrue(os.path.isfile(res))
  
  
-     @support.requires_zlib
-+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
++    @unittest.skipIf(True, "The Guix build container has no root user")
+     @support.requires_zlib()
      @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
      def test_tarfile_root_owner(self):
-         root_dir, base_dir = self._create_files()
+diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
+index 45553a6a42..55623f01a3 100644
+--- a/Lib/test/test_signal.py
++++ b/Lib/test/test_signal.py
+@@ -78,6 +78,7 @@ class PosixTests(unittest.TestCase):
+         self.assertLess(len(s), signal.NSIG)
+ 
+     @unittest.skipUnless(sys.executable, "sys.executable required.")
++    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+     def test_keyboard_interrupt_exit_code(self):
+         """KeyboardInterrupt triggers exit via SIGINT."""
+         process = subprocess.run(
+@@ -128,6 +129,7 @@ class WindowsSignalTests(unittest.TestCase):
+             signal.signal(7, handler)
+ 
+     @unittest.skipUnless(sys.executable, "sys.executable required.")
++    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+     def test_keyboard_interrupt_exit_code(self):
+         """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
+         # We don't test via os.kill(os.getpid(), signal.CTRL_C_EVENT) here
+@@ -1245,6 +1247,7 @@ class StressTest(unittest.TestCase):
+ 
+ class RaiseSignalTest(unittest.TestCase):
+ 
++    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+     def test_sigint(self):
+         with self.assertRaises(KeyboardInterrupt):
+             signal.raise_signal(signal.SIGINT)
+@@ -1275,6 +1278,7 @@ class RaiseSignalTest(unittest.TestCase):
+ 
+ class PidfdSignalTest(unittest.TestCase):
+ 
++    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
+     @unittest.skipUnless(
+         hasattr(signal, "pidfd_send_signal"),
+         "pidfd support not built in",
 diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
+index aefba4f397..6c89f558d5 100755
 --- a/Lib/test/test_socket.py
 +++ b/Lib/test/test_socket.py
-@@ -875,6 +875,8 @@ class GeneralModuleTests(unittest.TestCase):
+@@ -1009,6 +1009,8 @@ class GeneralModuleTests(unittest.TestCase):
          if not fqhn in all_host_names:
              self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
  
 +    @unittest.skipUnless(support.is_resource_enabled('network'),
 +                         'network is not enabled')
      def test_host_resolution(self):
-         for addr in [support.HOSTv4, '10.0.0.1', '255.255.255.255']:
+         for addr in [socket_helper.HOSTv4, '10.0.0.1', '255.255.255.255']:
              self.assertEqual(socket.gethostbyname(addr), addr)
-@@ -1004,6 +1006,8 @@ class GeneralModuleTests(unittest.TestCase):
+@@ -1140,6 +1142,8 @@ class GeneralModuleTests(unittest.TestCase):
              self.assertWarns(DeprecationWarning, socket.ntohs, k)
              self.assertWarns(DeprecationWarning, socket.htons, k)
  
@@ -225,7 +302,7 @@ diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
      def testGetServBy(self):
          eq = self.assertEqual
          # Find one service that exists, then check all the related interfaces.
-@@ -1358,6 +1362,8 @@ class GeneralModuleTests(unittest.TestCase):
+@@ -1489,6 +1493,8 @@ class GeneralModuleTests(unittest.TestCase):
              raise
          self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)
  
@@ -234,7 +311,7 @@ diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
      def testGetaddrinfo(self):
          try:
              socket.getaddrinfo('localhost', 80)
-@@ -1440,6 +1446,8 @@ class GeneralModuleTests(unittest.TestCase):
+@@ -1571,6 +1577,8 @@ class GeneralModuleTests(unittest.TestCase):
          # only IP addresses are allowed
          self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)
  
@@ -244,6 +321,7 @@ diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
                           'network is not enabled')
      def test_idna(self):
 diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
+index 07793c84c8..fec672bcbe 100644
 --- a/Lib/test/test_spwd.py
 +++ b/Lib/test/test_spwd.py
 @@ -5,8 +5,7 @@ from test import support
@@ -267,9 +345,10 @@ diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
  
      def test_getspnam_exception(self):
 diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
+index 29cde91bf7..8d0f20e8bf 100644
 --- a/Lib/test/test_tarfile.py
 +++ b/Lib/test/test_tarfile.py
-@@ -2509,9 +2509,12 @@ def root_is_uid_gid_0():
+@@ -2607,9 +2607,12 @@ def root_is_uid_gid_0():
          import pwd, grp
      except ImportError:
          return False
@@ -286,9 +365,10 @@ diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
      return True
  
 diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
+index c21cdf8eb7..6c9d575032 100644
 --- a/Lib/test/test_threading.py
 +++ b/Lib/test/test_threading.py
-@@ -1249,6 +1249,7 @@ class MiscTestCase(unittest.TestCase):
+@@ -1398,6 +1398,7 @@ class MiscTestCase(unittest.TestCase):
  
  
  class InterruptMainTests(unittest.TestCase):
@@ -296,7 +376,7 @@ diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
      def test_interrupt_main_subthread(self):
          # Calling start_new_thread with a function that executes interrupt_main
          # should raise KeyboardInterrupt upon completion.
-@@ -1260,6 +1261,8 @@ class InterruptMainTests(unittest.TestCase):
+@@ -1409,6 +1410,8 @@ class InterruptMainTests(unittest.TestCase):
              t.join()
          t.join()
  
@@ -305,10 +385,23 @@ diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
      def test_interrupt_main_mainthread(self):
          # Make sure that if interrupt_main is called in main thread that
          # KeyboardInterrupt is raised instantly.
+diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
+index b552d2bd17..28b1144e15 100644
+--- a/Lib/test/test_unicodedata.py
++++ b/Lib/test/test_unicodedata.py
+@@ -309,6 +309,7 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
+                 self.assertEqual(len(lines), 1,
+                                  r"\u%.4x should not be a linebreak" % i)
+ 
++@requires_resource('network')
+ class NormalizationTest(unittest.TestCase):
+     @staticmethod
+     def check_version(testfile):
 diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
+index bcfa5e943b..1f2484971b 100644
 --- a/Tools/scripts/run_tests.py
 +++ b/Tools/scripts/run_tests.py
-@@ -39,7 +39,7 @@ def main(regrtest_args):
+@@ -41,7 +41,7 @@ def main(regrtest_args):
      if not any(is_multiprocess_flag(arg) for arg in regrtest_args):
          args.extend(['-j', '0'])  # Use all CPU cores
      if not any(is_resource_use_flag(arg) for arg in regrtest_args):
@@ -317,3 +410,6 @@ diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
      args.extend(regrtest_args)
      print(' '.join(args))
      if sys.platform == 'win32':
+-- 
+2.29.2
+
diff --git a/gnu/packages/patches/python-3.8-fix-tests.patch b/gnu/packages/patches/python-3.8-fix-tests.patch
deleted file mode 100644
index 4fbdd444c7..0000000000
--- a/gnu/packages/patches/python-3.8-fix-tests.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
-index 1474624..887f8ee 100644
---- a/Lib/test/_test_multiprocessing.py
-+++ b/Lib/test/_test_multiprocessing.py
-@@ -3801,6 +3801,7 @@ class _TestSharedMemory(BaseTestCase):
-         sms.close()
-
-     @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
-+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
-     def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
-         # bpo-36368: protect SharedMemoryManager server process from
-         # KeyboardInterrupt signals.
-diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
-index d41e94b..a1c15e7 100644
---- a/Lib/test/test_signal.py
-+++ b/Lib/test/test_signal.py
-@@ -78,6 +78,7 @@ class PosixTests(unittest.TestCase):
-         self.assertLess(len(s), signal.NSIG)
-
-     @unittest.skipUnless(sys.executable, "sys.executable required.")
-+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
-     def test_keyboard_interrupt_exit_code(self):
-         """KeyboardInterrupt triggers exit via SIGINT."""
-         process = subprocess.run(
-@@ -128,6 +129,7 @@ class WindowsSignalTests(unittest.TestCase):
-             signal.signal(7, handler)
-
-     @unittest.skipUnless(sys.executable, "sys.executable required.")
-+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
-     def test_keyboard_interrupt_exit_code(self):
-         """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
-         # We don't test via os.kill(os.getpid(), signal.CTRL_C_EVENT) here
-@@ -1245,6 +1247,7 @@ class StressTest(unittest.TestCase):
-
- class RaiseSignalTest(unittest.TestCase):
-
-+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
-     def test_sigint(self):
-         with self.assertRaises(KeyboardInterrupt):
-             signal.raise_signal(signal.SIGINT)
---
-2.23.0
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 25ad86f204..85eb797fd9 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -54,7 +54,7 @@
 ;;; Copyright © 2018 Nicolas Goaziou <mail@nicolasgoaziou.fr>
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
 ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
-;;; Copyright © 2018, 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2018, 2019, 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2018 Luther Thompson <lutheroto@gmail.com>
 ;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
 ;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
@@ -361,25 +361,24 @@ data types.")
     (name "python")
     (properties `((superseded . ,python-2)))))
 
-(define-public python-3.8
+(define-public python-3.9
   (package
     (inherit python-2)
     (name "python")
-    (version "3.8.5")
+    (version "3.9.1")
     (source (origin
               (method url-fetch)
               (uri (string-append "https://www.python.org/ftp/python/"
                                   version "/Python-" version ".tar.xz"))
               (patches (search-patches
                         "python-3-arm-alignment.patch"
-                        "python-3-fix-tests.patch"
-                        "python-3.8-fix-tests.patch"
                         "python-3-deterministic-build-info.patch"
-                        "python-3-search-paths.patch"
-                        "python-3-hurd-configure.patch"))
+                        "python-3-fix-tests.patch"
+                        "python-3-hurd-configure.patch"
+                        "python-3-search-paths.patch"))
               (sha256
                (base32
-                "1c43dbv9lvlp3ynqmgdi4rh8q94swanhqarqrdx62zmigpakw073"))
+                "1zq3k4ymify5ig739zyvx9s2ainvchxb1zpy139z74krr653y74r"))
               (modules '((guix build utils)))
               (snippet
                '(begin
@@ -394,11 +393,8 @@ data types.")
        ((#:make-flags _)
         `(list (string-append
                 (format #f "TESTOPTS=-j~d" (parallel-job-count))
-                ;; test_mmap fails on low-memory systems.
-                " --exclude test_mmap"
-                ;; test_socket may hang and eventually run out of memory
-                ;; on some systems: <https://bugs.python.org/issue34587>.
-                " test_socket"
+                ;; test_mmap fails on low-memory systems
+                " --exclude test_mmap test_socket"
                 ,@(if (hurd-target?)
                       '(" test_posix"      ;multiple errors
                         " test_time"
@@ -444,12 +440,6 @@ data types.")
                                        (or native-inputs inputs) "tzdata")
                                       "/share/zoneinfo"))
                #t))
-           ;; Unset SOURCE_DATE_EPOCH while running the test-suite and set it
-           ;; again afterwards.  See <https://bugs.python.org/issue34022>.
-           (add-before 'check 'unset-SOURCE_DATE_EPOCH
-             (lambda _ (unsetenv "SOURCE_DATE_EPOCH") #t))
-           (add-after 'check 'reset-SOURCE_DATE_EPOCH
-             (lambda _ (setenv "SOURCE_DATE_EPOCH" "1") #t))
            (replace 'rebuild-bytecode
              (lambda* (#:key outputs #:allow-other-keys)
                (let ((out (assoc-ref outputs "out")))
@@ -458,22 +448,21 @@ data types.")
                  (setenv "PYTHONHASHSEED" "0")
                  (for-each
                   (lambda (opt)
-                    (format #t "Compiling with optimization level: ~a\n"
-                            (if (null? opt) "none" (car opt)))
-                    (for-each (lambda (file)
-                                (apply invoke
-                                       `(,,(if (%current-target-system)
-                                               "python3"
-                                               '(string-append out
-                                                               "/bin/python3"))
-                                         ,@opt
-                                         "-m" "compileall"
-                                         "-f" ; force rebuild
-                                         ;; Don't build lib2to3, because it's Python 2 code.
-                                         "-x" "lib2to3/.*"
-                                         ,file)))
-                              (find-files out "\\.py$")))
-                  (list '() '("-O") '("-OO")))
+                    (format #t "Compiling with optimization level: ~a\n" opt)
+                    (lambda (file)
+                      (apply invoke
+                             `(,,(if (%current-target-system)
+                                     "python3"
+                                     '(string-append out
+                                                     "/bin/python3"))
+                               ,opt
+                               "-m" "compileall"
+                               "-f" ; force rebuild
+                               "--invalidation-mode=unchecked-hash"
+                               ;; Don't build lib2to3, because it's Python 2 code.
+                               "-x" "lib2to3/.*"
+                               ,out))))
+                  (list "none" "-O" "-OO"))
                  #t)))))))
     (native-inputs
      `(("tzdata" ,tzdata-for-tests)
@@ -489,7 +478,7 @@ data types.")
                                         "/site-packages"))))))))
 
 ;; Current 3.x version.
-(define-public python-3 python-3.8)
+(define-public python-3 python-3.9)
 
 ;; Current major version.
 (define-public python python-3)