This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Logging captured warnings with a format string unnecessarily groups warnings together
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.11
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, mnito, vinay.sajip
Priority: normal Keywords: patch

Created on 2022-01-28 00:38 by mnito, last changed 2022-04-11 14:59 by admin.

File name Uploaded Description Edit
Screen Shot 2022-01-27 at 8.09.37 PM.png mnito, 2022-01-28 01:12 Screenshot of Sentry UI
Pull Requests
URL Status Linked Edit
PR 30975 merged mnito, 2022-01-28 00:49
Messages (4)
msg411947 - (view) Author: Michael P. Nitowski (mnito) * Date: 2022-01-28 00:38
Systems that aggregate logs like Sentry will group all captured warnings under the same event which makes it difficult to assess common warnings
msg411950 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2022-01-28 00:47
Could you give an example of the problem?
msg411956 - (view) Author: Michael P. Nitowski (mnito) * Date: 2022-01-28 01:12
Of course, here's an example script to reproduce:

import logging
import warnings

import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration


sentry_logging = LoggingIntegration(

    "<ingest URL>",

warnings.warn("A warning")
warnings.warn("Another warning")

I attached a file of what it looks like in the Sentry UI. Notice both warnings under the same issue. When logging warnings directly with the logging module, each message arrives as a separate issue. These warnings from the warnings module are both grouped together under the same issue since Sentry groups all logs with the same format string together.
msg415228 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2022-03-15 09:01
New changeset d8066b420b888591f485d132e62979d07abfc3f4 by Michael P. Nitowski in branch 'main':
bpo-46557: Log captured warnings without format string (GH-30975)
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90715
2022-03-15 09:01:07vinay.sajipsetnosy: + vinay.sajip
messages: + msg415228
2022-01-28 15:48:08vinay.sajipsettype: behavior -> enhancement
versions: - Python 3.7, Python 3.8, Python 3.9, Python 3.10
2022-01-28 01:12:42mnitosetfiles: + Screen Shot 2022-01-27 at 8.09.37 PM.png

messages: + msg411956
2022-01-28 00:49:58mnitosetkeywords: + patch
stage: patch review
pull_requests: + pull_request29154
2022-01-28 00:47:51eric.smithsetnosy: + eric.smith
messages: + msg411950
2022-01-28 00:38:52mnitocreate