Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-2586

Changes to support Python 3.10

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.12, 4.0
    • Affects Version/s: None
    • Component/s: None
    • None

      There are a few changes required to support Python 3.10:

      The test/utils.py module is importing a few types that moved from the collections module to the collections.abc module back in Python 3.3. Those types no longer exist in collections. This problem only affects a small subset of our test suite. The driver itself is fine.

      As of Python 3.10 distutils is deprecated, to be removed in Python 3.12. Our setup.py imports a host of features from distutils that will have to be replaced.

      https://docs.python.org/3.10/whatsnew/3.10.html#distutils
      https://www.python.org/dev/peps/pep-0632/
      https://www.python.org/dev/peps/pep-0632/#migration-advice
      https://setuptools.readthedocs.io/en/latest/deprecated/distutils-legacy.html

      from distutils.cmd import Command
      from distutils.command.build_ext import build_ext
      from distutils.errors import CCompilerError, DistutilsOptionError
      from distutils.errors import DistutilsPlatformError, DistutilsExecError
      from distutils.core import Extension
      

      Can be replaced by:

      from setuptools import Command
      from setuptools.command.build_ext import build_ext
      from setuptools.extension import Extension
      

      Note that setuptools doesn't expose the the exception types from distutils.errors or provide a replacement. We'll just catch Exception instead. Catching the explicit distutils exceptions happened way back in the early histlry of PyMongo, but doesn't seem strictly necessary.

      Finally, we need to add Python 3.10 to the test matrix.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: