From 1f2b19c8ad7235f5632a170c91e766462884813e Mon Sep 17 00:00:00 2001
From: starlet-dx <15929766099@163.com>
Date: Sun, 23 Jul 2023 15:19:02 +0800
Subject: [PATCH 1/1] Support Python 3.11

Refer:
https://gitlab.com/mailman/mailman/-/commit/1954815f32fea4d9d920cdc74f63bcc24d3b6c49
---
 src/mailman/runners/lmtp.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py
index a653275..0fc45bf 100644
--- a/src/mailman/runners/lmtp.py
+++ b/src/mailman/runners/lmtp.py
@@ -35,7 +35,6 @@ so that the peer mail server can provide better diagnostics.
 """
 
 import email
-import asyncio
 import logging
 
 from aiosmtpd.controller import Controller
@@ -126,9 +125,13 @@ def split_recipient(address):
 
 
 class LMTPHandler:
-    @asyncio.coroutine
+    async def handle_RCPT(self, server, session, envelope, to, rcpt_options):
+        # Use a helper function to use the transactional wrapper on since it
+        # doesn't yet work on awaitables (async def funcs.)
+        return self._handle_RCPT(server, session, envelope, to, rcpt_options)
+
     @transactional
-    def handle_RCPT(self, server, session, envelope, to, rcpt_options):
+    def _handle_RCPT(self, server, session, envelope, to, rcpt_options):
         listnames = set(getUtility(IListManager).names)
         try:
             to = parseaddr(to)[1].lower()
@@ -164,9 +167,13 @@ class LMTPHandler:
             config.db.abort()
             return ERR_550
 
-    @asyncio.coroutine
+    async def handle_DATA(self, server, session, envelope):
+        # Use a helper function to use the transactional wrapper on since it
+        # doesn't yet work on awaitables (async def funcs.)
+        return self._handle_DATA(server, session, envelope)
+
     @transactional
-    def handle_DATA(self, server, session, envelope):
+    def _handle_DATA(self, server, session, envelope):
         try:
             # Refresh the list of list names every time we process a message
             # since the set of mailing lists could have changed.
-- 
2.30.0

