From 50b74517d5d0158cb6d5535f5d40345bcc559f32 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 22 Nov 2022 10:48:17 +0000 Subject: [PATCH 1/2] Add distutils.log.Log back for compatibility --- distutils/log.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/distutils/log.py b/distutils/log.py index bb789c30..5a849c9d 100644 --- a/distutils/log.py +++ b/distutils/log.py @@ -5,6 +5,7 @@ """ import logging +import warnings from ._log import log as _global_log @@ -36,3 +37,21 @@ def set_verbosity(v): set_threshold(logging.INFO) elif v >= 2: set_threshold(logging.DEBUG) + + +class Log(logging.Logger): + """distutils.log.Logger is deprecated, please use an alternative from `logging`.""" + + def __init__(self, threshold=WARN): + warnings.warn(Log.__doc__) # avoid DeprecationWarning to ensure warn is shown + super().__init__(__name__, level=threshold) + + @property + def threshold(self): + return self.level + + @threshold.setter + def threshold(self, level): + self.setLevel(level) + + warn = logging.Logger.warning From 4811c1e3e1e0c3f6d51bd8a32a91f022c299ba95 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 22 Nov 2022 11:26:22 +0000 Subject: [PATCH 2/2] Ignore deprecation warning in tests --- distutils/log.py | 2 +- pytest.ini | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/distutils/log.py b/distutils/log.py index 5a849c9d..239f3158 100644 --- a/distutils/log.py +++ b/distutils/log.py @@ -40,7 +40,7 @@ def set_verbosity(v): class Log(logging.Logger): - """distutils.log.Logger is deprecated, please use an alternative from `logging`.""" + """distutils.log.Log is deprecated, please use an alternative from `logging`.""" def __init__(self, threshold=WARN): warnings.warn(Log.__doc__) # avoid DeprecationWarning to ensure warn is shown diff --git a/pytest.ini b/pytest.ini index 2eb4976d..3f8cc25f 100644 --- a/pytest.ini +++ b/pytest.ini @@ -24,3 +24,6 @@ filterwarnings= # suppress warnings in deprecated compilers ignore:(bcpp|msvc9?)compiler is deprecated + + # suppress well know deprecation warning + ignore:distutils.log.Log is deprecated