From 05fc55ab04d1a98b5702481c7338fd07722653f3 Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: May 21 2020 10:56:31 +0000 Subject: Backport an upstream commit for Python 3.9 compatibility Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1814243 --- diff --git a/b75af1bc.patch b/b75af1bc.patch new file mode 100644 index 0000000..ee686d4 --- /dev/null +++ b/b75af1bc.patch @@ -0,0 +1,70 @@ +From b75af1bcdf90e44f4f8906bc3fd07d7f1583da99 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Mon, 18 May 2020 15:58:37 +0200 +Subject: [PATCH] Don't use dummy_threading in tests, the module is gone in + Python 3.9 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The suggested usage of `dummy_threading` is: + + try: + import threading + except ImportError: + import dummy_threading as threading + +To support installations without the threading module: + https://docs.python.org/3.6/library/dummy_threading.html + +Installations without the threading module are no longer possible since Python 3.7: + https://docs.python.org/3.7/library/dummy_threading.html + +And hence this module was removed from Python 3.9. + https://bugs.python.org/issue37312 + +In the tests the dummy_thread module was used in a non-traditional way to +prevent the ComposerThread class from spawning new threads. +Instead, we reset the ComposerThread.start() and ComposerThread.join() methods. + +Fixes https://github.com/fedora-infra/bodhi/issues/4007 +Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1814243 + +Signed-off-by: Miro Hrončok +--- + bodhi/tests/server/tasks/test_composer.py | 13 +++++-------- + 1 file changed, 5 insertions(+), 8 deletions(-) + +diff --git a/bodhi/tests/server/tasks/test_composer.py b/bodhi/tests/server/tasks/test_composer.py +index a157e8f1f..f4a51d38b 100644 +--- a/bodhi/tests/server/tasks/test_composer.py ++++ b/bodhi/tests/server/tasks/test_composer.py +@@ -19,7 +19,6 @@ + from urllib.error import HTTPError, URLError + import urllib.parse as urlparse + import datetime +-import dummy_threading + import errno + import json + import os +@@ -153,15 +152,13 @@ def setup_method(self, method): + super(TestComposer, self).setup_method(method) + self._new_compose_stage_dir = tempfile.mkdtemp() + +- # Since the ComposerThread is a subclass of Thread and since it is already constructed +- # before we have a chance to alter it, we need to change its superclass to be +- # dummy_threading.Thread so that the test suite doesn't launch real Threads. Threads cannot ++ # We don't want the test suite to launch real Threads. Threads cannot + # use the same database sessions, and that means that changes that threads make will not + # appear in other thread's sessions, which cause a lot of problems in these tests. +- # Mock was not able to make this change since the __bases__ attribute cannot be removed, but +- # we don't really need this to be cleaned up since we don't want any tests launching theads +- # anyway. +- ComposerThread.__bases__ = (dummy_threading.Thread,) ++ # We don't really need this to be cleaned up since we don't want any tests launching threads ++ # anyway, so we don't bother with mock. ++ ComposerThread.start = lambda self: self.run() ++ ComposerThread.join = lambda self, timeout=None: None + test_config = base.original_config.copy() + test_config['compose_stage_dir'] = self._new_compose_stage_dir + test_config['compose_dir'] = os.path.join(self._new_compose_stage_dir, 'compose') diff --git a/bodhi.spec b/bodhi.spec index 9965241..0afde75 100644 --- a/bodhi.spec +++ b/bodhi.spec @@ -22,6 +22,9 @@ URL: https://github.com/fedora-infra/bodhi Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz #Source0: %{url}/archive/%{commit}/%{name}-%{commit}.tar.gz +# Python 3.9 compatibility +Patch1: %{url}/commit/b75af1bc.patch + BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: %{py3_dist alembic}