Date: Sunday, December 5, 2021 @ 22:29:18 Author: foutrelis Revision: 1065209
Add fixes for Python 3.10 Added: python-aiosmtpd/trunk/python310.patch Modified: python-aiosmtpd/trunk/PKGBUILD -----------------+ PKGBUILD | 12 +++-- python310.patch | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+), 3 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2021-12-05 21:44:45 UTC (rev 1065208) +++ PKGBUILD 2021-12-05 22:29:18 UTC (rev 1065209) @@ -11,12 +11,18 @@ depends=('python-atpublic' 'python-attrs') makedepends=('python-setuptools') checkdepends=('python-pytest' 'python-pytest-mock') -source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz") -sha512sums=('b910ae4c00b52f59b9f2199b296a1b76caa7567cbcd2e27c73d4ec894e9b48cd8190090083ce33b87dc924c4394a6425506355951208af65b89a6c1abe371114') -b2sums=('9a725d3aa28943afbb14fb6792e0115cf4bc257250da815183c9c9e6b293cf71ac836cc811f50e48bc450d3f629f74d1948aaef78d44852bc96fb3daf0398605') +source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz" + python310.patch) +sha512sums=('b910ae4c00b52f59b9f2199b296a1b76caa7567cbcd2e27c73d4ec894e9b48cd8190090083ce33b87dc924c4394a6425506355951208af65b89a6c1abe371114' + '68d65360fcf4efa23b000536eba141c4af15206595183efb415a1f75c82eb025e697cce8c99d437a462fb38a3a37f3e0980ba0be8e730f8d8b0c95fb85c12d62') +b2sums=('9a725d3aa28943afbb14fb6792e0115cf4bc257250da815183c9c9e6b293cf71ac836cc811f50e48bc450d3f629f74d1948aaef78d44852bc96fb3daf0398605' + '527f7b695560c8d1ae4f86409a2af529f25ef786aa3c6f69c3cd5d2bdab78f399195edf62f8eaae09d422f129d3ec3ef166368e6c0cd4e4f0ed26e6c8a7c80eb') prepare() { mv -v "${_name}-$pkgver" "$pkgname-$pkgver" + + # https://github.com/aio-libs/aiosmtpd/pull/294 + patch -Np1 -d "$pkgname-$pkgver" <python310.patch } build() { Added: python310.patch =================================================================== --- python310.patch (rev 0) +++ python310.patch 2021-12-05 22:29:18 UTC (rev 1065209) @@ -0,0 +1,125 @@ +From 9f504dff28faf122c7c8a60aa823e0c9a34415fd Mon Sep 17 00:00:00 2001 +From: Evangelos Foutras <evange...@foutrelis.com> +Date: Sun, 5 Dec 2021 21:28:22 +0200 +Subject: [PATCH 1/3] Create client-specific SSLContext for probes + +Reusing the server context is not possible in Python 3.10: + + ssl.SSLError: Cannot create a client socket with a + PROTOCOL_TLS_SERVER context (_ssl.c:801) + +(cherry picked from commit ddc9c7316e1f7fb4f47136d0c94292dad15db069) +--- + aiosmtpd/controller.py | 10 ++++++++-- + aiosmtpd/tests/test_server.py | 5 ++++- + 2 files changed, 12 insertions(+), 3 deletions(-) + +diff --git a/aiosmtpd/controller.py b/aiosmtpd/controller.py +index 2258c54..9204a68 100644 +--- a/aiosmtpd/controller.py ++++ b/aiosmtpd/controller.py +@@ -312,7 +312,10 @@ class Controller(BaseThreadedController): + with ExitStack() as stk: + s = stk.enter_context(create_connection((hostname, self.port), 1.0)) + if self.ssl_context: +- s = stk.enter_context(self.ssl_context.wrap_socket(s)) ++ context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH) ++ context.check_hostname = False ++ context.verify_mode = ssl.CERT_NONE ++ s = stk.enter_context(context.wrap_socket(s)) + _ = s.recv(1024) + + +@@ -355,5 +358,8 @@ class UnixSocketController(BaseThreadedController): # pragma: on-win32 on-cygwi + s: makesock = stk.enter_context(makesock(AF_UNIX, SOCK_STREAM)) + s.connect(self.unix_socket) + if self.ssl_context: +- s = stk.enter_context(self.ssl_context.wrap_socket(s)) ++ context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH) ++ context.check_hostname = False ++ context.verify_mode = ssl.CERT_NONE ++ s = stk.enter_context(context.wrap_socket(s)) + _ = s.recv(1024) +diff --git a/aiosmtpd/tests/test_server.py b/aiosmtpd/tests/test_server.py +index 99c5630..6b99495 100644 +--- a/aiosmtpd/tests/test_server.py ++++ b/aiosmtpd/tests/test_server.py +@@ -334,7 +334,10 @@ class TestUnixSocketController: + ) + sock.connect(str(self.sockfile)) + if ssl_context: +- sock = stk.enter_context(ssl_context.wrap_socket(sock)) ++ context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH) ++ context.check_hostname = False ++ context.verify_mode = ssl.CERT_NONE ++ sock = stk.enter_context(context.wrap_socket(sock)) + time.sleep(0.1) + resp = sock.recv(1024) + assert resp.startswith(b"220 ") + +From d4bf099b006e145f774277a16993df70919a5341 Mon Sep 17 00:00:00 2001 +From: Evangelos Foutras <evange...@foutrelis.com> +Date: Sun, 5 Dec 2021 21:38:54 +0200 +Subject: [PATCH 2/3] Limit bpo-27820 xfail to older Python versions + +(bpo-27820: Possible bug in smtplib when initial_response_ok=False) + +(cherry picked from commit cdc56aa1fd9a2745ec6d4e22b1a1f79b7f0c9b06) +--- + aiosmtpd/tests/test_smtp.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/aiosmtpd/tests/test_smtp.py b/aiosmtpd/tests/test_smtp.py +index 6fd8bfb..5e79b09 100644 +--- a/aiosmtpd/tests/test_smtp.py ++++ b/aiosmtpd/tests/test_smtp.py +@@ -7,6 +7,7 @@ import asyncio + import itertools + import logging + import socket ++import sys + import time + import warnings + from base64 import b64encode +@@ -1050,7 +1051,9 @@ class TestAuthMechanisms(_CommonMethods): + client.user = "goodlogin" + client.password = PW + auth_meth = getattr(client, "auth_" + mechanism) +- if (mechanism, init_resp) == ("login", False): ++ if (mechanism, init_resp) == ("login", False) and ( ++ sys.version_info < (3, 8, 9) or sys.version_info < (3, 9, 3)): ++ # bpo-27820 was fixed for 3.10 and backported to 3.8.9 and 3.9.3 + with pytest.raises(SMTPAuthenticationError): + client.auth(mechanism, auth_meth, initial_response_ok=init_resp) + client.docmd("*") + +From e7724b48a6da7913f2b492f85067abf4d8398465 Mon Sep 17 00:00:00 2001 +From: Evangelos Foutras <evange...@foutrelis.com> +Date: Sun, 5 Dec 2021 23:45:50 +0200 +Subject: [PATCH 3/3] Mark 'test_warn_authreqnotls' xfail on Python 3.10 + +Ignoring the following test failure until it's fixed properly. + +aiosmtpd/tests/test_smtp.py::TestAuthArgs::test_warn_authreqnotls + aiosmtpd/aiosmtpd/smtp.py:329: DeprecationWarning: + There is no current event loop + self.loop = loop if loop else asyncio.get_event_loop() + +(cherry picked from commit f93395fc1a74dabce5cca203d89aa348fb74fbba) +--- + aiosmtpd/tests/test_smtp.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/aiosmtpd/tests/test_smtp.py b/aiosmtpd/tests/test_smtp.py +index 5e79b09..c286754 100644 +--- a/aiosmtpd/tests/test_smtp.py ++++ b/aiosmtpd/tests/test_smtp.py +@@ -1930,6 +1930,8 @@ class TestTimeout(_CommonMethods): + + + class TestAuthArgs: ++ @pytest.mark.xfail(sys.version_info >= (3, 10), ++ reason="asyncio.get_event_loop raises DeprecationWarning (bpo-39529)") + def test_warn_authreqnotls(self, caplog): + with pytest.warns(UserWarning) as record: + _ = Server(Sink(), auth_required=True, auth_require_tls=False)