You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
- Removes manual overrides of copy behavior and leaves it up to the caller.
- E.g. a future use case may require a non-deepcopy. If we override copy they would have to remove the dunder copy, update every implementation which relies copy, before finally creating their own copy implementation.
- Deepcopies the flag buffer.
- Though we do not cache mutable references yet we may soon and so this foot gun should be removed from possibility.
- Removes "copy" test coverage from `test_lru_cache.py`. We're no longer assuming copy usage and leave it up to the caller.
- The existing test in `tests/test_scope.py` covers the cache pollution case [originally mentioned here](#3852).
- The mutable cache pollution case is not covered because we do not currently cache mutable objects.
In general a generic class should assume as few implementation details as possible. If we leave the existing copy method someone may assume copy semantics and rely on it in a way that is inappropriate.
Closes: #3886
Co-authored-by: Anton Pirker <[email protected]>
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.
The text was updated successfully, but these errors were encountered: