bpo-46557: Log captured warnings without format string (GH-30975)

This commit is contained in:
Michael P. Nitowski 2022-03-15 05:01:03 -04:00 committed by GitHub
parent 16995ed0f2
commit d8066b420b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -2246,7 +2246,9 @@ def _showwarning(message, category, filename, lineno, file=None, line=None):
logger = getLogger("py.warnings")
if not logger.handlers:
logger.addHandler(NullHandler())
logger.warning("%s", s)
# bpo-46557: Log str(s) as msg instead of logger.warning("%s", s)
# since some log aggregation tools group logs by the msg arg
logger.warning(str(s))
def captureWarnings(capture):
"""

View file

@ -0,0 +1 @@
Warnings captured by the logging module are now logged without a format string to prevent systems that group logs by the msg argument from grouping captured warnings together.