From 396d5340d11278f474844a19e45649232cf7ade9 Mon Sep 17 00:00:00 2001 From: Neel Shah Date: Wed, 4 Dec 2024 20:12:42 +0100 Subject: [PATCH] Fix scope client reference on copy/fork --- sentry_sdk/scope.py | 1 + tests/test_scope.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 54e6fc8928..f03827b30d 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -202,6 +202,7 @@ def __copy__(self): rv = object.__new__(self.__class__) # type: Scope rv._type = self._type + rv.client = self.client rv._level = self._level rv._name = self._name rv._fingerprint = self._fingerprint diff --git a/tests/test_scope.py b/tests/test_scope.py index 48b8782190..316b9ed335 100644 --- a/tests/test_scope.py +++ b/tests/test_scope.py @@ -23,6 +23,7 @@ use_scope, use_isolation_scope, ) +from tests.conftest import ApproxDict SLOTS_NOT_COPIED = {"client"} @@ -806,8 +807,8 @@ def test_nested_scopes_with_tags(sentry_init, capture_envelopes): transaction = envelope.items[0].get_transaction_event() assert transaction["tags"] == {"isolation_scope1": 1, "current_scope2": 1, "trx": 1} - assert transaction["spans"][0]["tags"] == {"a": 1} - assert transaction["spans"][1]["tags"] == {"b": 1} + assert transaction["spans"][0]["tags"] == ApproxDict({"a": 1}) + assert transaction["spans"][1]["tags"] == ApproxDict({"b": 1}) def test_should_send_default_pii_true(sentry_init):