Skip to content

Commit f8ff99d

Browse files
committed
PYTHON-2586 Changes to support Python 3.10
1 parent b03e598 commit f8ff99d

File tree

3 files changed

+38
-21
lines changed

3 files changed

+38
-21
lines changed

.evergreen/config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,10 @@ axes:
18851885
display_name: "Python 3.9"
18861886
variables:
18871887
PYTHON_BINARY: "/opt/python/3.9/bin/python3"
1888+
- id: "3.10"
1889+
display_name: "Python 3.10"
1890+
variables:
1891+
PYTHON_BINARY: "/opt/python/3.10/bin/python3"
18881892
- id: "pypy"
18891893
display_name: "PyPy"
18901894
variables:
@@ -1947,6 +1951,10 @@ axes:
19471951
display_name: "Python 3.9"
19481952
variables:
19491953
PYTHON_BINARY: "C:/python/Python39/python.exe"
1954+
- id: "3.10"
1955+
display_name: "Python 3.10"
1956+
variables:
1957+
PYTHON_BINARY: "C:/python/Python310/python.exe"
19501958

19511959
- id: python-version-windows-32
19521960
display_name: "Python"
@@ -1979,6 +1987,10 @@ axes:
19791987
display_name: "32-bit Python 3.9"
19801988
variables:
19811989
PYTHON_BINARY: "C:/python/32/Python39/python.exe"
1990+
- id: "3.10"
1991+
display_name: "32-bit Python 3.10"
1992+
variables:
1993+
PYTHON_BINARY: "C:/python/32/Python310/python.exe"
19821994

19831995
# Choice of mod_wsgi version
19841996
- id: mod-wsgi-version
@@ -2269,6 +2281,17 @@ buildvariants:
22692281
display_name: "${python-version} ${platform} ${auth} ${ssl} ${coverage}"
22702282
tasks: *all-server-versions
22712283

2284+
- matrix_name: "tests-python-version-ubuntu20-ssl"
2285+
matrix_spec:
2286+
platform: ubuntu-20.04
2287+
python-version: ["3.10"]
2288+
auth-ssl: "*"
2289+
display_name: "${python-version} ${platform} ${auth-ssl} ${coverage}"
2290+
tasks:
2291+
- ".latest"
2292+
- ".5.0"
2293+
- ".4.4"
2294+
22722295
- matrix_name: "tests-pyopenssl"
22732296
matrix_spec:
22742297
platform: awslinux

setup.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@
2424
use_setuptools()
2525
from setuptools import setup, __version__ as _setuptools_version
2626

27-
from distutils.cmd import Command
28-
from distutils.command.build_ext import build_ext
29-
from distutils.errors import CCompilerError, DistutilsOptionError
30-
from distutils.errors import DistutilsPlatformError, DistutilsExecError
31-
from distutils.core import Extension
27+
28+
if sys.version_info[:2] < (3, 10):
29+
from distutils.cmd import Command
30+
from distutils.command.build_ext import build_ext
31+
from distutils.core import Extension
32+
else:
33+
from setuptools import Command
34+
from setuptools.command.build_ext import build_ext
35+
from setuptools.extension import Extension
3236

3337
_HAVE_SPHINX = True
3438
try:
@@ -89,7 +93,7 @@ def finalize_options(self):
8993
if self.test_suite is None and self.test_module is None:
9094
self.test_module = 'test'
9195
elif self.test_module is not None and self.test_suite is not None:
92-
raise DistutilsOptionError(
96+
raise Exception(
9397
"You may specify a module or suite, but not both"
9498
)
9599

@@ -223,15 +227,6 @@ def output_difference(self, example, got, optionflags):
223227
" %s/\n" % (mode, path))
224228

225229

226-
if sys.platform == 'win32':
227-
# distutils.msvc9compiler can raise an IOError when failing to
228-
# find the compiler
229-
build_errors = (CCompilerError, DistutilsExecError,
230-
DistutilsPlatformError, IOError)
231-
else:
232-
build_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
233-
234-
235230
class custom_build_ext(build_ext):
236231
"""Allow C extension building to fail.
237232
@@ -284,7 +279,7 @@ class custom_build_ext(build_ext):
284279
def run(self):
285280
try:
286281
build_ext.run(self)
287-
except DistutilsPlatformError:
282+
except Exception:
288283
e = sys.exc_info()[1]
289284
sys.stdout.write('%s\n' % str(e))
290285
warnings.warn(self.warning_message % ("Extension modules",
@@ -296,7 +291,7 @@ def build_extension(self, ext):
296291
name = ext.name
297292
try:
298293
build_ext.build_extension(self, ext)
299-
except build_errors:
294+
except Exception:
300295
e = sys.exc_info()[1]
301296
sys.stdout.write('%s\n' % str(e))
302297
warnings.warn(self.warning_message % ("The %s extension "

test/utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"""Utilities for testing pymongo
1616
"""
1717

18-
import collections
1918
import contextlib
2019
import copy
2120
import functools
@@ -32,7 +31,7 @@
3231

3332
from bson import json_util, py3compat
3433
from bson.objectid import ObjectId
35-
from bson.py3compat import iteritems, string_type
34+
from bson.py3compat import abc, iteritems, string_type
3635
from bson.son import SON
3736

3837
from pymongo import (MongoClient,
@@ -300,11 +299,11 @@ class ScenarioDict(dict):
300299
"""Dict that returns {} for any unknown key, recursively."""
301300
def __init__(self, data):
302301
def convert(v):
303-
if isinstance(v, collections.Mapping):
302+
if isinstance(v, abc.Mapping):
304303
return ScenarioDict(v)
305304
if isinstance(v, (py3compat.string_type, bytes)):
306305
return v
307-
if isinstance(v, collections.Sequence):
306+
if isinstance(v, abc.Sequence):
308307
return [convert(item) for item in v]
309308
return v
310309

0 commit comments

Comments
 (0)