diff options
author | Victor Stinner <vstinner@python.org> | 2021-04-16 09:26:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-16 09:26:40 (GMT) |
commit | 69ca32e0d34fe17dd242592b6f8754cda7bae684 (patch) | |
tree | 3b0fa21b63e80f33d7dc4cf5da84b9861a9591fc /Lib/distutils | |
parent | a6a5c91b1ee56fa5ba7ab8c5aeca70c31cc85fd3 (diff) | |
download | cpython-69ca32e0d34fe17dd242592b6f8754cda7bae684.zip cpython-69ca32e0d34fe17dd242592b6f8754cda7bae684.tar.gz cpython-69ca32e0d34fe17dd242592b6f8754cda7bae684.tar.bz2 |
bpo-41282: Fix distutils.utils.byte_compile() DeprecationWarning (GH-25406)
* byte_compile() of distutils.utils no longer logs a
DeprecationWarning
* test_distutils no longer logs a DeprecationWarning
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/__init__.py | 7 | ||||
-rw-r--r-- | Lib/distutils/util.py | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/Lib/distutils/__init__.py b/Lib/distutils/__init__.py index 8eef902..fdad6f6 100644 --- a/Lib/distutils/__init__.py +++ b/Lib/distutils/__init__.py @@ -13,7 +13,8 @@ import warnings __version__ = sys.version[:sys.version.index(' ')] -warnings.warn("The distutils package is deprecated and slated for " - "removal in Python 3.12. Use setuptools or check " - "PEP 632 for potential alternatives", +_DEPRECATION_MESSAGE = ("The distutils package is deprecated and slated for " + "removal in Python 3.12. Use setuptools or check " + "PEP 632 for potential alternatives") +warnings.warn(_DEPRECATION_MESSAGE, DeprecationWarning, 2) diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py index 4b002ec..2ce5c5b 100644 --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -9,6 +9,7 @@ import re import importlib.util import string import sys +import distutils from distutils.errors import DistutilsPlatformError from distutils.dep_util import newer from distutils.spawn import spawn @@ -419,8 +420,10 @@ byte_compile(files, optimize=%r, force=%r, direct=1) """ % (optimize, force, prefix, base_dir, verbose)) + msg = distutils._DEPRECATION_MESSAGE cmd = [sys.executable] cmd.extend(subprocess._optim_args_from_interpreter_flags()) + cmd.append(f'-Wignore:{msg}:DeprecationWarning') cmd.append(script_name) spawn(cmd, dry_run=dry_run) execute(os.remove, (script_name,), "removing %s" % script_name, |