Skip to content

Commit 3e9d47e

Browse files
authored
Merge pull request #192 from abravalheri/setuptools-issue-3693
Backfill `distutils.log.Log` for compatibility
2 parents e0787fa + 4811c1e commit 3e9d47e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

distutils/log.py

+19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import logging
8+
import warnings
89

910
from ._log import log as _global_log
1011

@@ -36,3 +37,21 @@ def set_verbosity(v):
3637
set_threshold(logging.INFO)
3738
elif v >= 2:
3839
set_threshold(logging.DEBUG)
40+
41+
42+
class Log(logging.Logger):
43+
"""distutils.log.Log is deprecated, please use an alternative from `logging`."""
44+
45+
def __init__(self, threshold=WARN):
46+
warnings.warn(Log.__doc__) # avoid DeprecationWarning to ensure warn is shown
47+
super().__init__(__name__, level=threshold)
48+
49+
@property
50+
def threshold(self):
51+
return self.level
52+
53+
@threshold.setter
54+
def threshold(self, level):
55+
self.setLevel(level)
56+
57+
warn = logging.Logger.warning

pytest.ini

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ filterwarnings=
2424

2525
# suppress warnings in deprecated compilers
2626
ignore:(bcpp|msvc9?)compiler is deprecated
27+
28+
# suppress well know deprecation warning
29+
ignore:distutils.log.Log is deprecated

0 commit comments

Comments
 (0)