Skip to content

Commit ce85ca0

Browse files
committed
PYTHON-5479 Drop support for Python 3.9
1 parent 0d93ec4 commit ce85ca0

40 files changed

+278
-528
lines changed

.evergreen/generated_configs/tasks.yml

Lines changed: 256 additions & 443 deletions
Large diffs are not rendered by default.

.evergreen/scripts/generate_config_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
##############
2323

2424
ALL_VERSIONS = ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "rapid", "latest"]
25-
CPYTHONS = ["3.10", "3.9", "3.11", "3.12", "3.13", "3.14"]
25+
CPYTHONS = ["3.10", "3.11", "3.12", "3.13", "3.14"]
2626
PYPYS = ["pypy3.10"]
2727
ALL_PYTHONS = CPYTHONS + PYPYS
2828
MIN_MAX_PYTHON = [CPYTHONS[0], CPYTHONS[-1]]

.evergreen/utils.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ find_python3() {
66
PYTHON=""
77
# Find a suitable toolchain version, if available.
88
if [ "$(uname -s)" = "Darwin" ]; then
9-
PYTHON="/Library/Frameworks/Python.Framework/Versions/3.9/bin/python3"
9+
PYTHON="/Library/Frameworks/Python.Framework/Versions/3.10/bin/python3"
1010
elif [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin
11-
PYTHON="C:/python/Python39/python.exe"
11+
PYTHON="C:/python/Python310/python.exe"
1212
else
13-
# Prefer our own toolchain, fall back to mongodb toolchain if it has Python 3.9+.
14-
if [ -f "/opt/python/3.9/bin/python3" ]; then
13+
# Prefer our own toolchain, fall back to mongodb toolchain if it has Python 3.10+.
14+
if [ -f "/opt/python/3.10/bin/python3" ]; then
1515
PYTHON="/opt/python/Current/bin/python3"
16-
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v5/bin/python3)"; then
16+
elif is_python_310 "$(command -v /opt/mongodbtoolchain/v5/bin/python3)"; then
1717
PYTHON="/opt/mongodbtoolchain/v5/bin/python3"
18-
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v4/bin/python3)"; then
18+
elif is_python_310 "$(command -v /opt/mongodbtoolchain/v4/bin/python3)"; then
1919
PYTHON="/opt/mongodbtoolchain/v4/bin/python3"
20-
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then
20+
elif is_python_310 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then
2121
PYTHON="/opt/mongodbtoolchain/v3/bin/python3"
2222
fi
2323
fi
24-
# Add a fallback system python3 if it is available and Python 3.9+.
24+
# Add a fallback system python3 if it is available and Python 3.10+.
2525
if [ -z "$PYTHON" ]; then
26-
if is_python_39 "$(command -v python3)"; then
26+
if is_python_310 "$(command -v python3)"; then
2727
PYTHON="$(command -v python3)"
2828
fi
2929
fi
3030
if [ -z "$PYTHON" ]; then
31-
echo "Cannot test without python3.9+ installed!"
31+
echo "Cannot test without python3.10+ installed!"
3232
exit 1
3333
fi
3434
echo "$PYTHON"
@@ -99,15 +99,15 @@ testinstall () {
9999
fi
100100
}
101101

102-
# Function that returns success if the provided Python binary is version 3.9 or later
102+
# Function that returns success if the provided Python binary is version 3.10 or later
103103
# Usage:
104-
# is_python_39 /path/to/python
104+
# is_python_310 /path/to/python
105105
# * param1: Python binary
106-
is_python_39() {
106+
is_python_310() {
107107
if [ -z "$1" ]; then
108108
return 1
109-
elif $1 -c "import sys; exit(sys.version_info[:2] < (3, 9))"; then
110-
# runs when sys.version_info[:2] >= (3, 9)
109+
elif $1 -c "import sys; exit(sys.version_info[:2] < (3, 10))"; then
110+
# runs when sys.version_info[:2] >= (3, 10)
111111
return 0
112112
else
113113
return 1
@@ -131,7 +131,7 @@ get_python_binary() {
131131
else
132132
PYTHON="/opt/python/$version/bin/python3"
133133
fi
134-
if is_python_39 "$(command -v $PYTHON)"; then
134+
if is_python_310 "$(command -v $PYTHON)"; then
135135
echo "$PYTHON"
136136
else
137137
echo "Could not find suitable python binary for '$version'" >&2

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.9+ and PyPy3.10+. Language features not
19+
PyMongo supports CPython 3.10+ and PyPy3.10+. 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.9+ and PyPy3.10+.
100+
PyMongo supports CPython 3.10+ and PyPy3.10+.
101101

102102
Required dependencies:
103103

doc/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ 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: Python 3.10+is now required.
10+
11+
- Dropped support for Python 3.9.
912
- Removed invalid documents from :class:`bson.errors.InvalidDocument` error messages as
1013
doing so may leak sensitive user data.
1114
Instead, invalid documents are stored in :attr:`bson.errors.InvalidDocument.document`.

pymongo/asynchronous/cursor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
from bson.code import Code
3838
from bson.son import SON
3939
from pymongo import _csot, helpers_shared
40-
from pymongo.asynchronous.helpers import anext
4140
from pymongo.collation import validate_collation_or_none
4241
from pymongo.common import (
4342
validate_is_document_type,

pymongo/asynchronous/helpers.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
from __future__ import annotations
1717

1818
import asyncio
19-
import builtins
2019
import socket
21-
import sys
2220
from typing import (
2321
Any,
2422
Callable,
@@ -86,17 +84,3 @@ async def _getaddrinfo(
8684
return await loop.getaddrinfo(host, port, **kwargs) # type: ignore[return-value]
8785
else:
8886
return socket.getaddrinfo(host, port, **kwargs)
89-
90-
91-
if sys.version_info >= (3, 10):
92-
anext = builtins.anext
93-
aiter = builtins.aiter
94-
else:
95-
96-
async def anext(cls: Any) -> Any:
97-
"""Compatibility function until we drop 3.9 support: https://docs.python.org/3/library/functions.html#anext."""
98-
return await cls.__anext__()
99-
100-
def aiter(cls: Any) -> Any:
101-
"""Compatibility function until we drop 3.9 support: https://docs.python.org/3/library/functions.html#anext."""
102-
return cls.__aiter__()

pymongo/synchronous/cursor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
_RawBatchQuery,
5656
)
5757
from pymongo.response import PinnedResponse
58-
from pymongo.synchronous.helpers import next
5958
from pymongo.typings import _Address, _CollationIn, _DocumentOut, _DocumentType
6059
from pymongo.write_concern import validate_boolean
6160

pymongo/synchronous/helpers.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
from __future__ import annotations
1717

1818
import asyncio
19-
import builtins
2019
import socket
21-
import sys
2220
from typing import (
2321
Any,
2422
Callable,
@@ -86,17 +84,3 @@ def _getaddrinfo(
8684
return loop.getaddrinfo(host, port, **kwargs) # type: ignore[return-value]
8785
else:
8886
return socket.getaddrinfo(host, port, **kwargs)
89-
90-
91-
if sys.version_info >= (3, 10):
92-
next = builtins.next
93-
iter = builtins.iter
94-
else:
95-
96-
def next(cls: Any) -> Any:
97-
"""Compatibility function until we drop 3.9 support: https://docs.python.org/3/library/functions.html#next."""
98-
return cls.__next__()
99-
100-
def iter(cls: Any) -> Any:
101-
"""Compatibility function until we drop 3.9 support: https://docs.python.org/3/library/functions.html#next."""
102-
return cls.__iter__()

0 commit comments

Comments
 (0)