Skip to content

Commit ee171a2

Browse files
authored
Stop using deprecated logging API in Sphinx suspicious checker (GH-9875)
1 parent 6bdb6f7 commit ee171a2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Doc/tools/extensions/suspicious.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
from docutils import nodes
5050
from sphinx.builders import Builder
51+
import sphinx.util
5152

5253
detect_all = re.compile(r'''
5354
::(?=[^=])| # two :: (but NOT ::=)
@@ -85,6 +86,7 @@ class CheckSuspiciousMarkupBuilder(Builder):
8586
Checks for possibly invalid markup that may leak into the output.
8687
"""
8788
name = 'suspicious'
89+
logger = sphinx.util.logging.getLogger("CheckSuspiciousMarkupBuilder")
8890

8991
def init(self):
9092
# create output file
@@ -116,7 +118,7 @@ def finish(self):
116118
self.warn('Found %s/%s unused rules:' %
117119
(len(unused_rules), len(self.rules)))
118120
for rule in unused_rules:
119-
self.info(repr(rule))
121+
self.logger.info(repr(rule))
120122
return
121123

122124
def check_issue(self, line, lineno, issue):
@@ -146,7 +148,7 @@ def is_ignored(self, line, lineno, issue):
146148
return False
147149

148150
def report_issue(self, text, lineno, issue):
149-
if not self.any_issue: self.info()
151+
if not self.any_issue: self.logger.info()
150152
self.any_issue = True
151153
self.write_log_entry(lineno, issue, text)
152154
if py3:
@@ -181,7 +183,7 @@ def load_rules(self, filename):
181183
A csv file, with exactly the same format as suspicious.csv
182184
Fields: document name (normalized), line number, issue, surrounding text
183185
"""
184-
self.info("loading ignore rules... ", nonl=1)
186+
self.logger.info("loading ignore rules... ", nonl=1)
185187
self.rules = rules = []
186188
try:
187189
if py3:
@@ -206,7 +208,7 @@ def load_rules(self, filename):
206208
rule = Rule(docname, lineno, issue, text)
207209
rules.append(rule)
208210
f.close()
209-
self.info('done, %d rules loaded' % len(self.rules))
211+
self.logger.info('done, %d rules loaded' % len(self.rules))
210212

211213

212214
def get_lineno(node):

0 commit comments

Comments
 (0)