Skip to content

Commit 029c74c

Browse files
authored
PYTHON-5670 Restore minimal support for Python 3.9 (#2640)
1 parent 0ce7686 commit 029c74c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+204
-11
lines changed

.evergreen/generated_configs/tasks.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,98 @@ tasks:
242242
TEST_MIN_DEPS: "1"
243243
tags: [test-min-deps, sharded_cluster-auth-ssl]
244244

245+
# Min support tests
246+
- name: test-min-support-python3.9-standalone-noauth-nossl
247+
commands:
248+
- func: run server
249+
- func: run tests
250+
vars:
251+
UV_PYTHON: "3.9"
252+
AUTH: noauth
253+
SSL: nossl
254+
TOPOLOGY: standalone
255+
tags: [test-min-support]
256+
- name: test-min-support-python3.9-replica-set-noauth-ssl
257+
commands:
258+
- func: run server
259+
- func: run tests
260+
vars:
261+
UV_PYTHON: "3.9"
262+
AUTH: noauth
263+
SSL: ssl
264+
TOPOLOGY: replica_set
265+
tags: [test-min-support]
266+
- name: test-min-support-python3.9-sharded-cluster-auth-ssl
267+
commands:
268+
- func: run server
269+
- func: run tests
270+
vars:
271+
UV_PYTHON: "3.9"
272+
AUTH: auth
273+
SSL: ssl
274+
TOPOLOGY: sharded_cluster
275+
tags: [test-min-support]
276+
- name: test-min-support-pypy3.9-standalone-noauth-nossl
277+
commands:
278+
- func: run server
279+
- func: run tests
280+
vars:
281+
UV_PYTHON: pypy3.9
282+
AUTH: noauth
283+
SSL: nossl
284+
TOPOLOGY: standalone
285+
tags: [test-min-support]
286+
- name: test-min-support-pypy3.9-replica-set-noauth-ssl
287+
commands:
288+
- func: run server
289+
- func: run tests
290+
vars:
291+
UV_PYTHON: pypy3.9
292+
AUTH: noauth
293+
SSL: ssl
294+
TOPOLOGY: replica_set
295+
tags: [test-min-support]
296+
- name: test-min-support-pypy3.9-sharded-cluster-auth-ssl
297+
commands:
298+
- func: run server
299+
- func: run tests
300+
vars:
301+
UV_PYTHON: pypy3.9
302+
AUTH: auth
303+
SSL: ssl
304+
TOPOLOGY: sharded_cluster
305+
tags: [test-min-support]
306+
- name: test-min-support-pypy3.10-standalone-noauth-nossl
307+
commands:
308+
- func: run server
309+
- func: run tests
310+
vars:
311+
UV_PYTHON: pypy3.10
312+
AUTH: noauth
313+
SSL: nossl
314+
TOPOLOGY: standalone
315+
tags: [test-min-support]
316+
- name: test-min-support-pypy3.10-replica-set-noauth-ssl
317+
commands:
318+
- func: run server
319+
- func: run tests
320+
vars:
321+
UV_PYTHON: pypy3.10
322+
AUTH: noauth
323+
SSL: ssl
324+
TOPOLOGY: replica_set
325+
tags: [test-min-support]
326+
- name: test-min-support-pypy3.10-sharded-cluster-auth-ssl
327+
commands:
328+
- func: run server
329+
- func: run tests
330+
vars:
331+
UV_PYTHON: pypy3.10
332+
AUTH: auth
333+
SSL: ssl
334+
TOPOLOGY: sharded_cluster
335+
tags: [test-min-support]
336+
245337
# Mod wsgi tests
246338
- name: mod-wsgi-replica-set-python3.10
247339
commands:

.evergreen/generated_configs/variants.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ buildvariants:
326326
expansions:
327327
TEST_NAME: load_balancer
328328

329+
# Min support tests
330+
- name: min-support-rhel8
331+
tasks:
332+
- name: .test-min-support
333+
display_name: Min Support RHEL8
334+
run_on:
335+
- rhel87-small
336+
329337
# Mockupdb tests
330338
- name: mockupdb-rhel8
331339
tasks:

.evergreen/scripts/generate_config.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,12 @@ def create_aws_auth_variants():
502502
return variants
503503

504504

505+
def create_min_support_variants():
506+
host = HOSTS["rhel8"]
507+
name = get_variant_name("Min Support", host=host)
508+
return [create_variant([".test-min-support"], name, host=host)]
509+
510+
505511
def create_no_server_variants():
506512
host = HOSTS["rhel8"]
507513
name = get_variant_name("No server", host=host)
@@ -897,6 +903,24 @@ def _create_ocsp_tasks(algo, variant, server_type, base_task_name):
897903
return tasks
898904

899905

906+
def create_min_support_tasks():
907+
server_func = FunctionCall(func="run server")
908+
from generate_config_utils import MIN_SUPPORT_VERSIONS
909+
910+
tasks = []
911+
for python, topology in product(MIN_SUPPORT_VERSIONS, TOPOLOGIES):
912+
auth, ssl = get_standard_auth_ssl(topology)
913+
vars = dict(UV_PYTHON=python, AUTH=auth, SSL=ssl, TOPOLOGY=topology)
914+
test_func = FunctionCall(func="run tests", vars=vars)
915+
task_name = get_task_name(
916+
"test-min-support", python=python, topology=topology, auth=auth, ssl=ssl
917+
)
918+
tags = ["test-min-support"]
919+
commands = [server_func, test_func]
920+
tasks.append(EvgTask(name=task_name, tags=tags, commands=commands))
921+
return tasks
922+
923+
900924
def create_aws_lambda_tasks():
901925
assume_func = FunctionCall(func="assume ec2 role")
902926
vars = dict(TEST_NAME="aws_lambda")

.evergreen/scripts/generate_config_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
ALL_VERSIONS = ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "rapid", "latest"]
2525
CPYTHONS = ["3.10", "3.11", "3.12", "3.13", "3.14t", "3.14"]
2626
PYPYS = ["pypy3.11"]
27+
MIN_SUPPORT_VERSIONS = ["3.9", "pypy3.9", "pypy3.10"]
2728
ALL_PYTHONS = CPYTHONS + PYPYS
2829
MIN_MAX_PYTHON = [CPYTHONS[0], CPYTHONS[-1]]
2930
BATCHTIME_WEEK = 10080

.github/workflows/dist.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ jobs:
8383
- name: Assert all versions in wheelhouse
8484
if: ${{ ! startsWith(matrix.buildplat[1], 'macos') }}
8585
run: |
86+
ls wheelhouse/*cp39*.whl
8687
ls wheelhouse/*cp310*.whl
8788
ls wheelhouse/*cp311*.whl
8889
ls wheelhouse/*cp312*.whl
@@ -110,7 +111,7 @@ jobs:
110111
- uses: actions/setup-python@v6
111112
with:
112113
# Build sdist on lowest supported Python
113-
python-version: "3.10"
114+
python-version: "3.9"
114115

115116
- name: Build SDist
116117
run: |

.github/workflows/test-python.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ jobs:
208208
cache: 'pip'
209209
cache-dependency-path: 'pyproject.toml'
210210
# Build sdist on lowest supported Python
211-
python-version: "3.10"
211+
python-version: "3.9"
212212
- name: Build SDist
213213
shell: bash
214214
run: |
@@ -242,7 +242,7 @@ jobs:
242242
cache: 'pip'
243243
cache-dependency-path: 'sdist/test/pyproject.toml'
244244
# Test sdist on lowest supported Python
245-
python-version: "3.10"
245+
python-version: "3.9"
246246
- id: setup-mongodb
247247
uses: mongodb-labs/drivers-evergreen-tools@master
248248
- name: Run connect test from sdist
@@ -266,7 +266,7 @@ jobs:
266266
- name: Install uv
267267
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7
268268
with:
269-
python-version: "3.10"
269+
python-version: "3.9"
270270
- id: setup-mongodb
271271
uses: mongodb-labs/drivers-evergreen-tools@master
272272
with:

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ be of interest or that has already been addressed.
1616

1717
## Supported Interpreters
1818

19-
PyMongo supports CPython 3.10+ and PyPy3.10+. Language features not
19+
PyMongo supports CPython 3.9+ and PyPy3.9+. Language features not
2020
supported by all interpreters can not be used.
2121

2222
## Style Guide

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ package that is incompatible with PyMongo.
9797

9898
## Dependencies
9999

100-
PyMongo supports CPython 3.10+ and PyPy3.10+.
100+
PyMongo supports CPython 3.9+ and PyPy3.9+.
101101

102102
Required dependencies:
103103

doc/changelog.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ Changes in Version 4.16.0 (XXXX/XX/XX)
66

77
PyMongo 4.16 brings a number of changes including:
88

9-
.. warning:: PyMongo 4.16 drops support for Python 3.9 and PyPy 3.10: Python 3.10+ or PyPy 3.11+ is now required.
10-
11-
- Dropped support for Python 3.9 and PyPy 3.10.
129
- Removed invalid documents from :class:`bson.errors.InvalidDocument` error messages as
1310
doing so may leak sensitive user data.
1411
Instead, invalid documents are stored in :attr:`bson.errors.InvalidDocument.document`.
15-
- PyMongo now requires ``dnspython>=2.6.1``, since ``dnspython`` 1.0 is no longer maintained and is incompatible with
16-
Python 3.10+. The minimum version is ``2.6.1`` to account for `CVE-2023-29483 <https://www.cve.org/CVERecord?id=CVE-2023-29483>`_.
12+
- PyMongo now requires ``dnspython>=2.6.1``, since ``dnspython`` 1.0 is no longer maintained.
13+
The minimum version is ``2.6.1`` to account for `CVE-2023-29483 <https://www.cve.org/CVERecord?id=CVE-2023-29483>`_.
1714
- Removed support for Eventlet.
1815
Eventlet is actively being sunset by its maintainers and has compatibility issues with PyMongo's dnspython dependency.
1916
- Use Zstandard support from the standard library for Python 3.14+, and use ``backports.zstd`` for older versions.

gridfs/asynchronous/grid_file.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from pymongo.asynchronous.collection import AsyncCollection
4747
from pymongo.asynchronous.cursor import AsyncCursor
4848
from pymongo.asynchronous.database import AsyncDatabase
49+
from pymongo.asynchronous.helpers import anext
4950
from pymongo.common import validate_string
5051
from pymongo.errors import (
5152
BulkWriteError,

0 commit comments

Comments
 (0)