MCPcopy Index your code
hub / github.com/RustPython/RustPython / _showwarning

Function _showwarning

Lib/logging/__init__.py:2303–2321  ·  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 the re

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

Source from the content-addressed store, hash-verified

2301_warnings_showwarning = None
2302
2303def _showwarning(message, category, filename, lineno, file=None, line=None):
2304 """
2305 Implementation of showwarnings which redirects to logging, which will first
2306 check to see if the file parameter is None. If a file is specified, it will
2307 delegate to the original warnings implementation of showwarning. Otherwise,
2308 it will call warnings.formatwarning and will log the resulting string to a
2309 warnings logger named "py.warnings" with level logging.WARNING.
2310 """
2311 if file is not None:
2312 if _warnings_showwarning is not None:
2313 _warnings_showwarning(message, category, filename, lineno, file, line)
2314 else:
2315 s = warnings.formatwarning(message, category, filename, lineno, line)
2316 logger = getLogger("py.warnings")
2317 if not logger.handlers:
2318 logger.addHandler(NullHandler())
2319 # bpo-46557: Log str(s) as msg instead of logger.warning("%s", s)
2320 # since some log aggregation tools group logs by the msg arg
2321 logger.warning(str(s))
2322
2323def captureWarnings(capture):
2324 """

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected