From 99d63c49bbe23e2acb2fc80b28aa8f1f8499608c Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 4 Jul 2025 14:47:01 +0200 Subject: [PATCH] Add comment about error assigning in frame.report_usage (#148105) --- homeassistant/helpers/frame.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/homeassistant/helpers/frame.py b/homeassistant/helpers/frame.py index d7a647e02eb..8f0741b5166 100644 --- a/homeassistant/helpers/frame.py +++ b/homeassistant/helpers/frame.py @@ -193,6 +193,11 @@ def report_usage( exclude_integrations=exclude_integrations ) except MissingIntegrationFrame as err: + # We need to be careful with assigning the error here as it affects the + # cleanup of objects referenced from the stack trace as seen in + # https://github.com/home-assistant/core/pull/148021#discussion_r2182379834 + # When core_behavior is ReportBehavior.ERROR, we will re-raise the error, + # so we can safely assign it to integration_frame_err. if core_behavior is ReportBehavior.ERROR: integration_frame_err = err _report_usage_partial = functools.partial(