Skip to content

Commit 32bcfe7

Browse files
author
Steven Silvester
authored
MOTOR-1054 motor.motor_asyncio is broken for Python 3.11 (#185)
1 parent fb8ea58 commit 32bcfe7

8 files changed

Lines changed: 77 additions & 41 deletions

File tree

.evergreen/config.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,10 @@ axes:
819819
variables:
820820
TOX_ENV: "tornado6-py39"
821821
PYTHON_BINARY: "/opt/python/3.9/bin/python3"
822+
- id: "tornado6-py310"
823+
variables:
824+
TOX_ENV: "tornado6-py310"
825+
PYTHON_BINARY: "/opt/python/3.10/bin/python3"
822826
- id: "tornado_git-py37"
823827
variables:
824828
TOX_ENV: "tornado_git-py37"
@@ -843,6 +847,10 @@ axes:
843847
variables:
844848
TOX_ENV: "asyncio-py39"
845849
PYTHON_BINARY: "/opt/python/3.9/bin/python3"
850+
- id: "asyncio-py310"
851+
variables:
852+
TOX_ENV: "asyncio-py310"
853+
PYTHON_BINARY: "/opt/python/3.10/bin/python3"
846854
- id: "py3-pymongo-latest"
847855
variables:
848856
TOX_ENV: "py3-pymongo-latest"
@@ -855,14 +863,14 @@ axes:
855863
- id: tox-env-ubuntu
856864
display_name: "Tox Env Ubuntu"
857865
values:
858-
- id: "tornado6-py310"
866+
- id: "tornado6-py311"
859867
variables:
860-
TOX_ENV: "tornado6-py310"
861-
PYTHON_BINARY: "/opt/python/3.10/bin/python3"
862-
- id: "asyncio-py310"
868+
TOX_ENV: "tornado6-py311"
869+
PYTHON_BINARY: "/opt/python/3.11/bin/python3"
870+
- id: "asyncio-py311"
863871
variables:
864-
TOX_ENV: "asyncio-py310"
865-
PYTHON_BINARY: "/opt/python/3.10/bin/python3"
872+
TOX_ENV: "asyncio-py311"
873+
PYTHON_BINARY: "/opt/python/3.11/bin/python3"
866874

867875
# Test Python 3.8 only on Mac.
868876
- id: tox-env-osx

.github/workflows/test-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
matrix:
2424
os: [ubuntu-latest]
25-
python-version: ["3.7", "3.10"]
25+
python-version: ["3.7", "3.11"]
2626
fail-fast: false
2727
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
2828
steps:

doc/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ Changelog
33

44
.. currentmodule:: motor.motor_tornado
55

6+
Motor 3.1.1
7+
-----------
8+
9+
Motor 3.1.1 adds support for Python 3.11 and fixes a bug that caused an
10+
``ImportError`` in Python 3.11.0.
11+
12+
613
Motor 3.1
714
---------
815

doc/examples/monitoring.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ See also:
8484
* The `Topology Monitoring`_ Spec
8585
* The `monitoring_example.py`_ example file in the Motor repository
8686

87-
.. _Command Monitoring: https://github.com/mongodb/specifications/blob/master/source/command-monitoring/command-monitoring.rst
87+
.. _Command Monitoring: https://github.com/mongodb/specifications/blob/master/source/command-logging-and-monitoring/command-logging-and-monitoring.rst
8888
.. _Topology Monitoring: https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring-monitoring.rst
8989
.. _monitoring_example.py: https://github.com/mongodb/motor/blob/master/doc/examples/monitoring_example.py

doc/requirements.rst

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Requirements
44
The current version of Motor requires:
55

66
* CPython 3.7 and later.
7-
* PyMongo_ 4.1 and later.
7+
* PyMongo_ 4.2 and later.
88

99
Motor can integrate with either Tornado or asyncio.
1010

@@ -49,6 +49,8 @@ Motor and PyMongo
4949
+-------------------+-----------------+
5050
| 3.0 | 4.1+ |
5151
+-------------------+-----------------+
52+
| 3.1 | 4.2+ |
53+
+-------------------+-----------------+
5254

5355
Motor and MongoDB
5456
`````````````````
@@ -80,6 +82,8 @@ Motor and MongoDB
8082
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
8183
| | 3.0 |**N**|**N**|**N**|**N**|**N**|**N**| Y | Y | Y | Y | Y |
8284
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
85+
| | 3.1 |**N**|**N**|**N**|**N**|**N**|**N**| Y | Y | Y | Y | Y |
86+
+---------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
8387

8488
There is no relationship between PyMongo and MongoDB version numbers, although
8589
the numbers happen to be close or equal in recent releases of PyMongo and MongoDB.
@@ -118,6 +122,8 @@ known to be incompatible, or have not been tested together.
118122
+---------------+-----+-----+-----+-----+-----+
119123
| | 3.0 |**N**|**N**|**N**| Y |
120124
+---------------+-----+-----+-----+-----+-----+
125+
| | 3.1 |**N**|**N**|**N**| Y |
126+
+---------------+-----+-----+-----+-----+-----+
121127

122128
Motor and Python
123129
````````````````
@@ -135,33 +141,37 @@ Motor 2.5 deprecated support for Python 3.5.
135141

136142
Motor 3.0 dropped support for Pythons older than 3.7.
137143

138-
+-------------------------------------------------------------------------------------+
139-
| Python Version |
140-
+=====================+=====+=====+=====+=======+=======+=====+=====+=====+=====+=====+
141-
| | 2.7 | 3.3 | 3.4 | 3.5.0 | 3.5.2 | 3.6 | 3.7 | 3.8 | 3.9 | 3.10|
142-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
143-
| Motor Version | 1.0 | Y | Y | Y | Y | Y | Y |**N**|**N**|**N**|**N**|
144-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
145-
| | 1.1 | Y | Y | Y | Y | Y | Y |**N**|**N**|**N**|**N**|
146-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
147-
| | 1.2 | Y |**N**| Y |**N** | Y | Y | Y |**N**|**N**|**N**|
148-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
149-
| | 1.3 | Y |**N**| Y |**N** | Y | Y | Y |**N**|**N**|**N**|
150-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
151-
| | 2.0 | Y |**N**| Y |**N** | Y | Y | Y |**N**|**N**|**N**|
152-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
153-
| | 2.1 | Y |**N**| Y |**N** | Y | Y | Y | Y |**N**|**N**|
154-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
155-
| | 2.2 |**N**|**N**|**N**|**N** | Y | Y | Y | Y |**N**|**N**|
156-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
157-
| | 2.3 |**N**|**N**|**N**|**N** | Y | Y | Y | Y |**N**|**N**|
158-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
159-
| | 2.4 |**N**|**N**|**N**|**N** | Y | Y | Y | Y | Y |**N**|
160-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
161-
| | 2.5 |**N**|**N**|**N**|**N** | Y | Y | Y | Y | Y | Y |
162-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
163-
| | 3.0 |**N**|**N**|**N**|**N** |**N** |**N**| Y | Y | Y | Y |
164-
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+
144+
Motor 3.1.1 added support for Python 3.11.
145+
146+
+-------------------------------------------------------------------------------------------+
147+
| Python Version |
148+
+=====================+=====+=====+=====+=======+=======+=====+=====+=====+=====+=====+=====+
149+
| | 2.7 | 3.3 | 3.4 | 3.5.0 | 3.5.2 | 3.6 | 3.7 | 3.8 | 3.9 | 3.10| 3.11|
150+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
151+
| Motor Version | 1.0 | Y | Y | Y | Y | Y | Y |**N**|**N**|**N**|**N**|**N**|
152+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
153+
| | 1.1 | Y | Y | Y | Y | Y | Y |**N**|**N**|**N**|**N**|**N**|
154+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
155+
| | 1.2 | Y |**N**| Y |**N** | Y | Y | Y |**N**|**N**|**N**|**N**|
156+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
157+
| | 1.3 | Y |**N**| Y |**N** | Y | Y | Y |**N**|**N**|**N**|**N**|
158+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
159+
| | 2.0 | Y |**N**| Y |**N** | Y | Y | Y |**N**|**N**|**N**|**N**|
160+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
161+
| | 2.1 | Y |**N**| Y |**N** | Y | Y | Y | Y |**N**|**N**|**N**|
162+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
163+
| | 2.2 |**N**|**N**|**N**|**N** | Y | Y | Y | Y |**N**|**N**|**N**|
164+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
165+
| | 2.3 |**N**|**N**|**N**|**N** | Y | Y | Y | Y |**N**|**N**|**N**|
166+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
167+
| | 2.4 |**N**|**N**|**N**|**N** | Y | Y | Y | Y | Y |**N**|**N**|
168+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
169+
| | 2.5 |**N**|**N**|**N**|**N** | Y | Y | Y | Y | Y | Y |**N**|
170+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
171+
| | 3.0 |**N**|**N**|**N**|**N** |**N** |**N**| Y | Y | Y | Y |**N**|
172+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
173+
| | 3.1 |**N**|**N**|**N**|**N** |**N** |**N**| Y | Y | Y | Y |**Y**|
174+
+---------------+-----+-----+-----+-----+-------+-------+-----+-----+-----+-----+-----+-----+
165175

166176
Not Supported
167177
-------------

motor/frameworks/asyncio/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,23 @@
2424
import multiprocessing
2525
import os
2626
import warnings
27-
from asyncio import coroutine, get_event_loop # noqa: F401 - For framework interface.
27+
from asyncio import get_event_loop # noqa: F401 - For framework interface.
2828
from concurrent.futures import ThreadPoolExecutor
2929

3030
try:
3131
import contextvars
3232
except ImportError:
3333
contextvars = None
3434

35+
try:
36+
from asyncio import coroutine
37+
except ImportError:
38+
39+
def coroutine():
40+
raise RuntimeError(
41+
"The coroutine decorator was removed in Python 3.11. Use 'async def' instead"
42+
)
43+
3544

3645
CLASS_PREFIX = "AsyncIO"
3746

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
Programming Language :: Python :: 3.8
2424
Programming Language :: Python :: 3.9
2525
Programming Language :: Python :: 3.10
26+
Programming Language :: Python :: 3.11
2627
Operating System :: MacOS :: MacOS X
2728
Operating System :: Unix
2829
Operating System :: Microsoft :: Windows

tox.ini

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ envlist =
99
tornado5-{py37},
1010

1111
# Tornado 6 supports Python 3.5+.
12-
tornado6-{pypy37,py37,py38,py39,py310},
12+
tornado6-{pypy37,py37,py38,py39,py310,py311},
1313

1414
# Test Tornado's dev version in a few configurations.
1515
tornado_git-{py37,py38},
@@ -21,7 +21,7 @@ envlist =
2121
py3-sphinx-doctest,
2222

2323
# asyncio without Tornado.
24-
asyncio-{py37,py38,py39,py310},
24+
asyncio-{py37,py38,py39,py310,py311},
2525

2626
# Test with the latest PyMongo.
2727
py3-pymongo-latest,
@@ -57,6 +57,7 @@ basepython =
5757
py38: {env:PYTHON_BINARY:python3.8}
5858
py39: {env:PYTHON_BINARY:python3.9}
5959
py310: {env:PYTHON_BINARY:python3.10}
60+
py311: {env:PYTHON_BINARY:python3.11}
6061
pypy37: {env:PYTHON_BINARY:pypy3}
6162

6263
# Default Python 3 when we don't care about minor version.
@@ -67,7 +68,7 @@ deps =
6768
tornado6: tornado>=6,<7
6869
tornado_git: git+https://github.com/tornadoweb/tornado.git
6970

70-
{py37,py38,py39,py310}: aiohttp
71+
{py37,py38,py39,py310,py311}: aiohttp
7172

7273
sphinx: sphinx
7374
sphinx: aiohttp
@@ -138,7 +139,7 @@ commands =
138139
# Map GitHub Actions python-version to environment using tox-github-actions.
139140
python =
140141
3.7: py37
141-
3.10: py310,manifest
142+
3.11: py311,manifest
142143

143144
[flake8]
144145
max-line-length = 100

0 commit comments

Comments
 (0)