From 6265b03cbf3d8ffadada0fd3e438132e7a6377be89ebf984e10edcd18f053f3b Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 4 Jul 2022 06:05:25 +0000 Subject: [PATCH] Accepting request 986502 from home:bnavigator:branches:devel:languages:python:mailman - Add hyperkitty-fix-py310-tests.patch * Fix test failures on Python 3.10 (and Python 3.9.13) * https://gitlab.com/mailman/hyperkitty/-/issues/401 * https://gitlab.com/mailman/hyperkitty/-/merge_requests/381 * https://gitlab.com/mailman/hyperkitty/-/merge_requests/449 OBS-URL: https://build.opensuse.org/request/show/986502 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:mailman/python-HyperKitty?expand=0&rev=55 --- hyperkitty-fix-py310-tests.patch | 102 +++++++++++++++++++++++++++++++ python-HyperKitty-rpmlintrc | 2 + python-HyperKitty.changes | 9 +++ python-HyperKitty.spec | 3 + 4 files changed, 116 insertions(+) create mode 100644 hyperkitty-fix-py310-tests.patch diff --git a/hyperkitty-fix-py310-tests.patch b/hyperkitty-fix-py310-tests.patch new file mode 100644 index 0000000..a39ac7f --- /dev/null +++ b/hyperkitty-fix-py310-tests.patch @@ -0,0 +1,102 @@ +From 2cda594bc0e7af5c0c24dcc3467ecea04be89f9e Mon Sep 17 00:00:00 2001 +From: David Runge +Date: Tue, 7 Dec 2021 22:46:17 +0100 +Subject: [PATCH 1/4] Ensure that date headers are valid + +hyperkitty/management/commands/hyperkitty_import.py: +Change `DbImporter._get_date()` to return None if a `Date:` header is +retrieved, that is not valid (its `datetime` attribute is set to +`None`). + +The email module has been reworked with python 3.10 to set the `Date:` +header string representation even if it is not valid, but ensures, that +its `datetime` attribute is set to None in that case: +https://github.com/python/cpython/commit/303aac8c56609290e122eecc14c038e9b1e4174a + +hyperkitty/tests/commands/test_import.py: +Change `test_ungettable_date()` to rely on differing error messages in +the output, depending on python version. With python 3.10 the logged +error message has changed. +--- + hyperkitty/management/commands/hyperkitty_import.py | 9 ++++++++- + hyperkitty/tests/commands/test_import.py | 7 ++++++- + 2 files changed, 14 insertions(+), 2 deletions(-) + +Index: HyperKitty-1.3.5/hyperkitty/management/commands/hyperkitty_import.py +=================================================================== +--- HyperKitty-1.3.5.orig/hyperkitty/management/commands/hyperkitty_import.py ++++ HyperKitty-1.3.5/hyperkitty/management/commands/hyperkitty_import.py +@@ -131,7 +131,14 @@ class DbImporter(object): + def _get_date(self, message, header, report_name): + try: + date = message.get(header) +- except (TypeError, ValueError) as e: ++ if date and not date.datetime: ++ if self.verbose: ++ self.stderr.write( ++ "Bad datetime in {} header in message {}{}.".format( ++ header, unquote(message.get("message-id", 'n/a')), ++ report_name)) ++ return None ++ except (AttributeError, TypeError, ValueError) as e: + if self.verbose: + self.stderr.write( + "Can't get {} header in message {}{}: {}.".format( +Index: HyperKitty-1.3.5/hyperkitty/tests/commands/test_import.py +=================================================================== +--- HyperKitty-1.3.5.orig/hyperkitty/tests/commands/test_import.py ++++ HyperKitty-1.3.5/hyperkitty/tests/commands/test_import.py +@@ -225,7 +225,12 @@ msg1 + # The message should be archived. + self.assertEqual(Email.objects.count(), 1) + # But there should be an error message. +- self.assertIn("Can't get date header in message", output.getvalue()) ++ if sys.hexversion < 0x30a0000: ++ self.assertIn("Can't get date header in message", ++ output.getvalue()) ++ else: ++ self.assertIn("Bad datetime in date header in message", ++ output.getvalue()) + + def test_no_date_but_resent_date(self): + # If there's no Dete: header, fall back to Resent-Date:. +Index: HyperKitty-1.3.5/tox.ini +=================================================================== +--- HyperKitty-1.3.5.orig/tox.ini ++++ HyperKitty-1.3.5/tox.ini +@@ -1,5 +1,5 @@ + [tox] +-envlist = py{36,37,38,39}-django{22,30,31,32},docs,qa ++envlist = py{36,37,38,39,310}-django{22,30,31,32},docs,qa + + + [testenv] +From 3efe7507944dbdbfcfa4c182d332528712476b28 Mon Sep 17 00:00:00 2001 +From: Mark Sapiro +Date: Thu, 16 Jun 2022 13:40:28 -0700 +Subject: [PATCH] Skip test_import.test_unconvertable_message where bpo-43323 + is fixed. + +--- + hyperkitty/tests/commands/test_import.py | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/hyperkitty/tests/commands/test_import.py b/hyperkitty/tests/commands/test_import.py +index 5284e0a8..c9c288bd 100644 +--- a/hyperkitty/tests/commands/test_import.py ++++ b/hyperkitty/tests/commands/test_import.py +@@ -364,6 +364,11 @@ msg1 + + def test_unconvertable_message(self): + # This message can't be converted to an email.message.EmailMessage. ++ # This fails with Python 3.9 >=3.9.13 and versions >= 3.10.5 because ++ # https://bugs.python.org/issue43323 is fixed. ++ if ((sys.hexversion >= 0x3090df0 and sys.hexversion < 0x30a0000) or ++ sys.hexversion >= 0x30a05f0): ++ raise SkipTest + mbox = mailbox.mbox(os.path.join(self.tmpdir, "test.mbox")) + # We have to do it this way to see the exception. + with open(get_test_file("unconvertable_message.txt"), "rb") as em_file: +-- +GitLab + diff --git a/python-HyperKitty-rpmlintrc b/python-HyperKitty-rpmlintrc index af1fb83..d098176 100644 --- a/python-HyperKitty-rpmlintrc +++ b/python-HyperKitty-rpmlintrc @@ -1,3 +1,5 @@ addFilter("zero-length") addFilter("non-standard-gid") addFilter("non-standard-uid") +addFilter("spurious-executable-perm .*example_project/wsgi.py") +addFilter("hidden-file-or-dir .*example_project/logs/.keep") diff --git a/python-HyperKitty.changes b/python-HyperKitty.changes index 44b699f..77cafce 100644 --- a/python-HyperKitty.changes +++ b/python-HyperKitty.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Sun Jul 3 20:46:20 UTC 2022 - Ben Greiner + +- Add hyperkitty-fix-py310-tests.patch + * Fix test failures on Python 3.10 (and Python 3.9.13) + * https://gitlab.com/mailman/hyperkitty/-/issues/401 + * https://gitlab.com/mailman/hyperkitty/-/merge_requests/381 + * https://gitlab.com/mailman/hyperkitty/-/merge_requests/449 + ------------------------------------------------------------------- Sat Jul 2 06:12:09 UTC 2022 - Andreas Schneider diff --git a/python-HyperKitty.spec b/python-HyperKitty.spec index 603b986..077b281 100644 --- a/python-HyperKitty.spec +++ b/python-HyperKitty.spec @@ -65,6 +65,8 @@ Patch2: hyperkitty-django4.patch Patch3: python-HyperKitty-no-mock.patch # https://gitlab.com/mailman/hyperkitty/-/commit/3edc0c58b8dea3b0bdccd77c0794ada28d1c6f61 Patch4: hyperkitty-fix-qcluster-timeout.patch +# https://gitlab.com/mailman/hyperkitty/-/merge_requests/381 + https://gitlab.com/mailman/hyperkitty/-/merge_requests/449 +Patch5: hyperkitty-fix-py310-tests.patch # BuildRequires: %{python_module django-debug-toolbar >= 2.2} BuildRequires: %{python_module isort} @@ -165,6 +167,7 @@ rsync -a example_project/* build_static_files %patch1 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 %build sed -i 's|^#!/usr/bin/env.*|#!%{_bindir}/python3|' \