# HG changeset patch # User Matt Harbison # Date 2023-03-08 04:38:14 # Node ID ada9a0245fd70ce1e8bdae75e655933d80c08d56 # Parent 0cc19a53cef4f58f707a18e095d2321b1a3e81fc run-tests: fix a crash when using the coverage options 35bf7f23b84c attempted to transition away from `distutils`, but the `packaging` code lacks `StrictVersion`. I have no idea when `packaging.version` became available, but I have it in python 3.6, so that should be good enough. For some reason, the import checker thinks this is a local import, and needs help to decide otherwise. Alternately we could ditch the version check entirely, because `coverage` is currently at 7.2.1, and the original check was added back in 2010. diff --git a/contrib/import-checker.py b/contrib/import-checker.py --- a/contrib/import-checker.py +++ b/contrib/import-checker.py @@ -232,6 +232,7 @@ def list_stdlib_modules(): yield 'importlib.abc' # python3 only yield 'importlib.machinery' # python3 only yield 'importlib.util' # python3 only + yield 'packaging.version' for m in 'fcntl', 'grp', 'pwd', 'termios': # Unix only yield m for m in 'cPickle', 'datetime': # in Python (not C) on PyPy diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -54,6 +54,7 @@ import functools import json import multiprocessing import os +import packaging.version as version import platform import queue import random @@ -72,12 +73,6 @@ import unittest import uuid import xml.dom.minidom as minidom -try: - # PEP 632 recommend the use of `packaging.version` to replace the - # deprecated `distutil.version`. So lets do it. - import packaging.version as version -except ImportError: - import distutils.version as version if sys.version_info < (3, 5, 0): print( @@ -799,8 +794,8 @@ def parseargs(args, parser): try: import coverage - covver = version.StrictVersion(coverage.__version__).version - if covver < (3, 3): + covver = version.Version(coverage.__version__) + if covver < version.Version("3.3"): parser.error('coverage options require coverage 3.3 or later') except ImportError: parser.error('coverage options now require the coverage package')