8000 bpo-46557: Log captured warnings without format string (GH-30975) · python/cpython@d8066b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit d8066b4

Browse files
authored
bpo-46557: Log captured warnings without format string (GH-30975)
1 parent 16995ed commit d8066b4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/logging/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,9 @@ def _showwarning(message, category, filename, lineno, file=None, line=None):
22462246
logger = getLogger("py.warnings")
22472247
if not logger.handlers:
22482248
logger.addHandler(NullHandler())
2249-
logger.warning("%s", s)
2249+
# bpo-46557: Log str(s) as msg instead of logger.warning("%s", s)
2250+
# since some log aggregation tools group logs by the msg arg
2251+
logger.warning(str(s))
22502252

22512253
def captureWarnings(capture):
22522254
"""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

0 commit comments

Comments
 (0)
0