MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _showwarning

Function _showwarning

tools/python-3.11.9-amd64/Lib/logging/__init__.py:2232–2250  ·  view source on GitHub ↗

Implementation of showwarnings which redirects to logging, which will first check to see if the file parameter is None. If a file is specified, it will delegate to the original warnings implementation of showwarning. Otherwise, it will call warnings.formatwarning and will log th

(message, category, filename, lineno, file=None, line=None)

Source from the content-addressed store, hash-verified

2230_warnings_showwarning = None
2231
2232def _showwarning(message, category, filename, lineno, file=None, line=None):
2233 """
2234 Implementation of showwarnings which redirects to logging, which will first
2235 check to see if the file parameter is None. If a file is specified, it will
2236 delegate to the original warnings implementation of showwarning. Otherwise,
2237 it will call warnings.formatwarning and will log the resulting string to a
2238 warnings logger named "py.warnings" with level logging.WARNING.
2239 """
2240 if file is not None:
2241 if _warnings_showwarning is not None:
2242 _warnings_showwarning(message, category, filename, lineno, file, line)
2243 else:
2244 s = warnings.formatwarning(message, category, filename, lineno, line)
2245 logger = getLogger("py.warnings")
2246 if not logger.handlers:
2247 logger.addHandler(NullHandler())
2248 # bpo-46557: Log str(s) as msg instead of logger.warning("%s", s)
2249 # since some log aggregation tools group logs by the msg arg
2250 logger.warning(str(s))
2251
2252def captureWarnings(capture):
2253 """

Callers

nothing calls this directly

Calls 5

strFunction · 0.85
addHandlerMethod · 0.80
getLoggerFunction · 0.70
NullHandlerClass · 0.70
warningMethod · 0.45

Tested by

no test coverage detected