Skip to content

Commit fdb5cdc

Browse files
authored
Merge branch 'master' into potel-base
2 parents bcadb61 + 26479b2 commit fdb5cdc

File tree

7 files changed

+40
-8
lines changed

7 files changed

+40
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 2.19.2
4+
5+
### Various fixes & improvements
6+
7+
- Deepcopy and ensure get_all function always terminates (#3861) by @cmanallen
8+
- Cleanup chalice test environment (#3858) by @antonpirker
9+
310
## 2.19.1
411

512
### Various fixes & improvements

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year)
3232
author = "Sentry Team and Contributors"
3333

34-
release = "2.19.1"
34+
release = "2.19.2"
3535
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3636

3737

scripts/ready_yet/requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
requests
2-
pathlib
3-
tox
2+
tox

sentry_sdk/_lru_cache.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
6363
"""
6464

65-
from copy import copy
65+
from copy import copy, deepcopy
6666

6767
SENTINEL = object()
6868

@@ -95,7 +95,7 @@ def __copy__(self):
9595
cache = LRUCache(self.max_size)
9696
cache.full = self.full
9797
cache.cache = copy(self.cache)
98-
cache.root = copy(self.root)
98+
cache.root = deepcopy(self.root)
9999
return cache
100100

101101
def set(self, key, value):
@@ -167,7 +167,15 @@ def get(self, key, default=None):
167167
def get_all(self):
168168
nodes = []
169169
node = self.root[NEXT]
170-
while node is not self.root:
170+
171+
# To ensure the loop always terminates we iterate to the maximum
172+
# size of the LRU cache.
173+
for _ in range(self.max_size):
174+
# The cache may not be full. We exit early if we've wrapped
175+
# around to the head.
176+
if node is self.root:
177+
break
171178
nodes.append((node[KEY], node[VALUE]))
172179
node = node[NEXT]
180+
173181
return nodes

sentry_sdk/consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,4 +567,4 @@ def _get_default_options():
567567
del _get_default_options
568568

569569

570-
VERSION = "2.19.1"
570+
VERSION = "2.19.2"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_file_text(file_name):
2121

2222
setup(
2323
name="sentry-sdk",
24-
version="2.19.1",
24+
version="2.19.2",
2525
author="Sentry Team and Contributors",
2626
author_email="[email protected]",
2727
url="https://github.com/getsentry/sentry-python",

tests/test_lru_cache.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
from copy import copy
23

34
from sentry_sdk._lru_cache import LRUCache
45

@@ -58,3 +59,20 @@ def test_cache_get_all():
5859
assert cache.get_all() == [(1, 1), (2, 2), (3, 3)]
5960
cache.get(1)
6061
assert cache.get_all() == [(2, 2), (3, 3), (1, 1)]
62+
63+
64+
def test_cache_copy():
65+
cache = LRUCache(3)
66+
cache.set(0, 0)
67+
cache.set(1, 1)
68+
69+
copied = copy(cache)
70+
cache.set(2, 2)
71+
cache.set(3, 3)
72+
assert copied.get_all() == [(0, 0), (1, 1)]
73+
assert cache.get_all() == [(1, 1), (2, 2), (3, 3)]
74+
75+
copied = copy(cache)
76+
cache.get(1)
77+
assert copied.get_all() == [(1, 1), (2, 2), (3, 3)]
78+
assert cache.get_all() == [(2, 2), (3, 3), (1, 1)]

0 commit comments

Comments
 (0)