Description: fix asyncio.coroutine import error with python3.11
Author: Steven Silvester
Bug: https://github.com/mongodb/motor/pull/185
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1031763
Reviewed-By: Étienne Mollier <emollier@debian.org>
Last-Update: 2023-03-03
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- python-motor.orig/motor/frameworks/asyncio/__init__.py
+++ python-motor/motor/frameworks/asyncio/__init__.py
@@ -25,7 +25,6 @@
 import os
 import warnings
 
-from asyncio import coroutine  # For framework interface.
 from concurrent.futures import ThreadPoolExecutor
 
 
@@ -34,6 +33,15 @@
 except ImportError:
     contextvars = None
 
+try:
+    from asyncio import coroutine
+except ImportError:
+
+    def coroutine():
+        raise RuntimeError(
+            "The coroutine decorator was removed in Python 3.11.  Use 'async def' instead"
+        )
+
 
 CLASS_PREFIX = 'AsyncIO'
 
