Skip to content

Commit 541b72d

Browse files
committed
Merge remote-tracking branch 'upstream/async-improvements' into PYTHON-4725
2 parents 6597803 + c2338d8 commit 541b72d

Some content is hidden

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

60 files changed

+921
-319
lines changed

.evergreen/config.yml

Lines changed: 74 additions & 141 deletions
Large diffs are not rendered by default.

.evergreen/utils.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set -o xtrace
44

55
find_python3() {
66
PYTHON=""
7-
# Add a fallback system python3 if it is available and Python 3.8+.
8-
if is_python_38 "$(command -v python3)"; then
7+
# Add a fallback system python3 if it is available and Python 3.9+.
8+
if is_python_39 "$(command -v python3)"; then
99
PYTHON="$(command -v python3)"
1010
fi
1111
# Find a suitable toolchain version, if available.
@@ -14,23 +14,23 @@ find_python3() {
1414
if [ -d "/Library/Frameworks/Python.Framework/Versions/3.10" ]; then
1515
PYTHON="/Library/Frameworks/Python.Framework/Versions/3.10/bin/python3"
1616
# macos 10.14
17-
elif [ -d "/Library/Frameworks/Python.Framework/Versions/3.8" ]; then
18-
PYTHON="/Library/Frameworks/Python.Framework/Versions/3.8/bin/python3"
17+
elif [ -d "/Library/Frameworks/Python.Framework/Versions/3.9" ]; then
18+
PYTHON="/Library/Frameworks/Python.Framework/Versions/3.9/bin/python3"
1919
fi
2020
elif [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
21-
PYTHON="C:/python/Python38/python.exe"
21+
PYTHON="C:/python/Python39/python.exe"
2222
else
23-
# Prefer our own toolchain, fall back to mongodb toolchain if it has Python 3.8+.
24-
if [ -f "/opt/python/3.8/bin/python3" ]; then
25-
PYTHON="/opt/python/3.8/bin/python3"
26-
elif is_python_38 "$(command -v /opt/mongodbtoolchain/v4/bin/python3)"; then
23+
# Prefer our own toolchain, fall back to mongodb toolchain if it has Python 3.9+.
24+
if [ -f "/opt/python/3.9/bin/python3" ]; then
25+
PYTHON="/opt/python/3.9/bin/python3"
26+
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v4/bin/python3)"; then
2727
PYTHON="/opt/mongodbtoolchain/v4/bin/python3"
28-
elif is_python_38 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then
28+
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then
2929
PYTHON="/opt/mongodbtoolchain/v3/bin/python3"
3030
fi
3131
fi
3232
if [ -z "$PYTHON" ]; then
33-
echo "Cannot test without python3.8+ installed!"
33+
echo "Cannot test without python3.9+ installed!"
3434
exit 1
3535
fi
3636
echo "$PYTHON"
@@ -96,15 +96,15 @@ testinstall () {
9696
fi
9797
}
9898

99-
# Function that returns success if the provided Python binary is version 3.8 or later
99+
# Function that returns success if the provided Python binary is version 3.9 or later
100100
# Usage:
101-
# is_python_38 /path/to/python
101+
# is_python_39 /path/to/python
102102
# * param1: Python binary
103-
is_python_38() {
103+
is_python_39() {
104104
if [ -z "$1" ]; then
105105
return 1
106-
elif $1 -c "import sys; exit(sys.version_info[:2] < (3, 8))"; then
107-
# runs when sys.version_info[:2] >= (3, 8)
106+
elif $1 -c "import sys; exit(sys.version_info[:2] < (3, 9))"; then
107+
# runs when sys.version_info[:2] >= (3, 9)
108108
return 0
109109
else
110110
return 1

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
uses: actions/checkout@v4
4040
with:
4141
ref: ${{ inputs.ref }}
42-
- uses: actions/setup-python@v3
42+
- uses: actions/setup-python@v5
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL

.github/workflows/dist.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- uses: actions/setup-python@v5
5454
with:
5555
cache: 'pip'
56-
python-version: 3.8
56+
python-version: 3.9
5757
cache-dependency-path: 'pyproject.toml'
5858
allow-prereleases: true
5959

@@ -67,7 +67,7 @@ jobs:
6767
# Note: the default manylinux is manylinux2014
6868
run: |
6969
python -m pip install -U pip
70-
python -m pip install "cibuildwheel>=2.17,<3"
70+
python -m pip install "cibuildwheel>=2.20,<3"
7171
7272
- name: Build wheels
7373
env:
@@ -79,17 +79,19 @@ jobs:
7979
env:
8080
CIBW_MANYLINUX_X86_64_IMAGE: manylinux1
8181
CIBW_MANYLINUX_I686_IMAGE: manylinux1
82-
CIBW_BUILD: "cp38-${{ matrix.buildplat[1] }} cp39-${{ matrix.buildplat[1] }}"
82+
CIBW_BUILD: "cp39-${{ matrix.buildplat[1] }} cp39-${{ matrix.buildplat[1] }}"
8383
run: python -m cibuildwheel --output-dir wheelhouse
8484

8585
- name: Assert all versions in wheelhouse
8686
if: ${{ ! startsWith(matrix.buildplat[1], 'macos') }}
8787
run: |
88-
ls wheelhouse/*cp38*.whl
8988
ls wheelhouse/*cp39*.whl
9089
ls wheelhouse/*cp310*.whl
9190
ls wheelhouse/*cp311*.whl
9291
ls wheelhouse/*cp312*.whl
92+
ls wheelhouse/*cp313*.whl
93+
# Free-threading builds:
94+
ls wheelhouse/*cp313t*.whl
9395
9496
- uses: actions/upload-artifact@v4
9597
with:
@@ -109,7 +111,7 @@ jobs:
109111
- uses: actions/setup-python@v5
110112
with:
111113
# Build sdist on lowest supported Python
112-
python-version: '3.8'
114+
python-version: '3.9'
113115

114116
- name: Build SDist
115117
run: |

.github/workflows/test-python.yml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/checkout@v4
2323
- uses: actions/setup-python@v5
2424
with:
25-
python-version: "3.8"
25+
python-version: "3.9"
2626
cache: 'pip'
2727
cache-dependency-path: 'pyproject.toml'
2828
- name: Install Python dependencies
@@ -51,11 +51,18 @@ jobs:
5151
strategy:
5252
matrix:
5353
os: [ubuntu-20.04]
54-
python-version: ["3.8", "pypy-3.9", "3.13"]
54+
python-version: ["3.9", "pypy-3.9", "3.13", "3.13t"]
5555
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
5656
steps:
5757
- uses: actions/checkout@v4
58-
- name: Setup Python
58+
- if: ${{ matrix.python-version == '3.13t' }}
59+
name: Setup free-threaded Python
60+
uses: deadsnakes/[email protected]
61+
with:
62+
python-version: 3.13
63+
nogil: true
64+
- if: ${{ matrix.python-version != '3.13t' }}
65+
name: Setup Python
5966
uses: actions/setup-python@v5
6067
with:
6168
python-version: ${{ matrix.python-version }}
@@ -65,19 +72,27 @@ jobs:
6572
- name: Install dependencies
6673
run: |
6774
pip install -U pip
68-
if [ "${{ matrix.python-version }}" == "3.13" ]; then
75+
if [[ "${{ matrix.python-version }}" == "3.13" ]]; then
6976
pip install --pre cffi setuptools
7077
pip install --no-build-isolation hatch
78+
elif [[ "${{ matrix.python-version }}" == "3.13t" ]]; then
79+
# Hatch can't be installed on 3.13t, use pytest directly.
80+
pip install .
81+
pip install -r requirements/test.txt
7182
else
7283
pip install hatch
7384
fi
7485
- name: Start MongoDB
75-
uses: supercharge/mongodb-github-action@1.10.0
86+
uses: supercharge/mongodb-github-action@1.11.0
7687
with:
7788
mongodb-version: 6.0
7889
- name: Run tests
7990
run: |
80-
hatch run test:test
91+
if [[ "${{ matrix.python-version }}" == "3.13t" ]]; then
92+
pytest -v --durations=5 --maxfail=10
93+
else
94+
hatch run test:test
95+
fi
8196
8297
doctest:
8398
runs-on: ubuntu-latest
@@ -87,14 +102,14 @@ jobs:
87102
- name: Setup Python
88103
uses: actions/setup-python@v5
89104
with:
90-
python-version: "3.8"
105+
python-version: "3.9"
91106
cache: 'pip'
92107
cache-dependency-path: 'pyproject.toml'
93108
- name: Install dependencies
94109
run: |
95110
pip install -U hatch pip
96111
- name: Start MongoDB
97-
uses: supercharge/mongodb-github-action@1.10.0
112+
uses: supercharge/mongodb-github-action@1.11.0
98113
with:
99114
mongodb-version: '8.0.0-rc4'
100115
- name: Run tests
@@ -111,7 +126,7 @@ jobs:
111126
cache: 'pip'
112127
cache-dependency-path: 'pyproject.toml'
113128
# Build docs on lowest supported Python for furo
114-
python-version: '3.8'
129+
python-version: '3.9'
115130
- name: Install dependencies
116131
run: |
117132
pip install -U pip hatch
@@ -129,7 +144,7 @@ jobs:
129144
cache: 'pip'
130145
cache-dependency-path: 'pyproject.toml'
131146
# Build docs on lowest supported Python for furo
132-
python-version: '3.8'
147+
python-version: '3.9'
133148
- name: Install dependencies
134149
run: |
135150
pip install -U pip hatch
@@ -142,7 +157,7 @@ jobs:
142157
runs-on: ubuntu-latest
143158
strategy:
144159
matrix:
145-
python: ["3.8", "3.11"]
160+
python: ["3.9", "3.11"]
146161
steps:
147162
- uses: actions/checkout@v4
148163
- uses: actions/setup-python@v5
@@ -167,7 +182,7 @@ jobs:
167182
cache: 'pip'
168183
cache-dependency-path: 'pyproject.toml'
169184
# Build sdist on lowest supported Python
170-
python-version: '3.8'
185+
python-version: '3.9'
171186
- name: Build SDist
172187
shell: bash
173188
run: |
@@ -199,9 +214,9 @@ jobs:
199214
cache: 'pip'
200215
cache-dependency-path: 'sdist/test/pyproject.toml'
201216
# Test sdist on lowest supported Python
202-
python-version: '3.8'
217+
python-version: '3.9'
203218
- name: Start MongoDB
204-
uses: supercharge/mongodb-github-action@1.10.0
219+
uses: supercharge/mongodb-github-action@1.11.0
205220
- name: Run connect test from sdist
206221
shell: bash
207222
run: |

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.8+ and PyPy3.9+. 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ a native Python driver for MongoDB. The `gridfs` package is a
1414
[gridfs](https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.rst/)
1515
implementation on top of `pymongo`.
1616

17-
PyMongo supports MongoDB 3.6, 4.0, 4.2, 4.4, 5.0, 6.0, 7.0, and 8.0.
17+
PyMongo supports MongoDB 4.0, 4.2, 4.4, 5.0, 6.0, 7.0, and 8.0.
1818

1919
## Support / Feedback
2020

@@ -90,7 +90,7 @@ package that is incompatible with PyMongo.
9090

9191
## Dependencies
9292

93-
PyMongo supports CPython 3.8+ and PyPy3.9+.
93+
PyMongo supports CPython 3.9+ and PyPy3.9+.
9494

9595
Required dependencies:
9696

bson/_cbsonmodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,6 +3184,9 @@ static PyModuleDef_Slot _cbson_slots[] = {
31843184
{Py_mod_exec, _cbson_exec},
31853185
#if defined(Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED)
31863186
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED},
3187+
#endif
3188+
#if PY_VERSION_HEX >= 0x030D0000
3189+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
31873190
#endif
31883191
{0, NULL},
31893192
};

doc/changelog.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
Changelog
22
=========
33

4+
Changes in Version 4.11.0
5+
-------------------------
6+
7+
.. warning:: PyMongo 4.11 drops support for Python 3.8: Python 3.9+ or PyPy 3.9+ is now required.
8+
.. warning:: PyMongo 4.11 drops support for MongoDB 3.6. PyMongo now supports MongoDB 4.0+.
9+
Driver support for MongoDB 3.6 reached end of life in April 2024.
10+
11+
PyMongo 4.11 brings a number of changes including:
12+
13+
- Dropped support for Python 3.8.
14+
- Dropped support for MongoDB 3.6.
15+
- Added support for free-threaded Python with the GIL disabled. For more information see:
16+
`Free-threaded CPython <https://docs.python.org/3.13/whatsnew/3.13.html#whatsnew313-free-threaded-cpython>`_.
17+
18+
Issues Resolved
19+
...............
20+
21+
See the `PyMongo 4.11 release notes in JIRA`_ for the list of resolved issues
22+
in this release.
23+
24+
.. _PyMongo 4.11 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=40784
25+
426
Changes in Version 4.10.1
527
-------------------------
628

doc/common-issues.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Also see the :ref:`TLSErrors` section.
66
Server reports wire version X, PyMongo requires Y
77
-------------------------------------------------
88

9-
When one attempts to connect to a <=3.4 version server, PyMongo will throw the following error::
9+
When one attempts to connect to a <=3.6 version server, PyMongo will throw the following error::
1010

1111
>>> client.admin.command('ping')
1212
...
13-
pymongo.errors.ConfigurationError: Server at localhost:27017 reports wire version 5, but this version of PyMongo requires at least 6 (MongoDB 3.6).
13+
pymongo.errors.ConfigurationError: Server at localhost:27017 reports wire version 6, but this version of PyMongo requires at least 7 (MongoDB 4.0).
1414

1515
This is caused by the driver being too new for the server it is being run against.
16-
To resolve this issue either upgrade your database to version >= 3.6 or downgrade to PyMongo 3.x which supports MongoDB >= 2.6.
16+
To resolve this issue either upgrade your database to version >= 4.0 or downgrade to an early version of PyMongo which supports MongoDB < 4.0.
1717

1818

1919
'Cursor' object has no attribute '_Cursor__killed'

0 commit comments

Comments
 (0)