forked from pool/python-HyperKitty
- 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
103 lines
4.4 KiB
Diff
103 lines
4.4 KiB
Diff
From 2cda594bc0e7af5c0c24dcc3467ecea04be89f9e Mon Sep 17 00:00:00 2001
|
|
From: David Runge <dave@sleepmap.de>
|
|
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 <mark@msapiro.net>
|
|
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
|
|
|