From f800b3430df40ae598b4571ad17f91b145020d0f Mon Sep 17 00:00:00 2001 From: Neel Shah Date: Thu, 5 Dec 2024 15:03:34 +0100 Subject: [PATCH] Copy scope.client reference as well --- sentry_sdk/scope.py | 1 + tests/test_scope.py | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 34ccc7f940..bb45143c48 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -225,6 +225,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 374a354446..a03eb07a99 100644 --- a/tests/test_scope.py +++ b/tests/test_scope.py @@ -19,10 +19,6 @@ ) -SLOTS_NOT_COPIED = {"client"} -"""__slots__ that are not copied when copying a Scope object.""" - - def test_copying(): s1 = Scope() s1.fingerprint = {} @@ -43,7 +39,7 @@ def test_all_slots_copied(): scope_copy = copy.copy(scope) # Check all attributes are copied - for attr in set(Scope.__slots__) - SLOTS_NOT_COPIED: + for attr in set(Scope.__slots__): assert getattr(scope_copy, attr) == getattr(scope, attr)