How do you use Sentry?
Sentry Saas (sentry.io)
Version
latest git revision
Steps to Reproduce
Mutable references are copied -- not the underlying value. This is visible here:
|
new._data = self._data.copy() |
Where we copy the _data attribute and not deepcopy.
class MutableObject:
def __init__(self):
self.count = 0
cache1 = LRUCache(max_size=2)
cache1.set(1, MutableObject())
cache2 = cache1.__copy__()
node = cache2.get(1)
node.count += 1
assert cache1.get(1).count == 0 # fail
assert cache2.get(1).count == 1
We should not be manually implementing __copy__ at all. This is a general helper class and should not assume copy semantics. I lay out this case in this comment and this comment.
Expected Result
Mutable objects do not pollute copied caches.
Actual Result
Mutable objects do pollute copied caches.
How do you use Sentry?
Sentry Saas (sentry.io)
Version
latest git revision
Steps to Reproduce
Mutable references are copied -- not the underlying value. This is visible here:
sentry-python/sentry_sdk/_lru_cache.py
Line 26 in f6281f5
We should not be manually implementing
__copy__at all. This is a general helper class and should not assume copy semantics. I lay out this case in this comment and this comment.Expected Result
Mutable objects do not pollute copied caches.
Actual Result
Mutable objects do pollute copied caches.