From 42ce065114d73b2a66b5b8548809c17246ee5440 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Mon, 15 Jul 2024 14:46:00 -0400 Subject: [PATCH 1/3] Test pickling twice. --- tiled/_tests/test_pickle.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tiled/_tests/test_pickle.py b/tiled/_tests/test_pickle.py index c68b6ac40..825de76bf 100644 --- a/tiled/_tests/test_pickle.py +++ b/tiled/_tests/test_pickle.py @@ -47,11 +47,17 @@ def test_pickle_clients(structure_clients, tmpdir): for segment in segements: original = original[segment] roundtripped = pickle.loads(pickle.dumps(original)) - assert roundtripped.uri == original.uri + roundtripped_twice = pickle.loads(pickle.dumps(roundtripped)) + assert roundtripped.uri == roundtripped_twice.uri == original.uri def test_lock_round_trip(tmpdir): cache = Cache(tmpdir / "http_response_cache.db") cache_round_tripped = pickle.loads(pickle.dumps(cache)) + cache_round_tripped_twice = pickle.loads(pickle.dumps(cache_round_tripped)) # implementation detail! - assert cache._lock.lock is cache_round_tripped._lock.lock + assert ( + cache._lock.lock + is cache_round_tripped._lock.lock + is cache_round_tripped_twice._lock.lock + ) From 9df2994384b3ea79c8aa58a483b89f4ee7f8881b Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Mon, 15 Jul 2024 14:46:10 -0400 Subject: [PATCH 2/3] Fix missed aspects of __getstate__. --- tiled/client/context.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tiled/client/context.py b/tiled/client/context.py index 8cfb2baa2..46b9d8271 100644 --- a/tiled/client/context.py +++ b/tiled/client/context.py @@ -238,6 +238,7 @@ def __setstate__(self, state): ) self.http_client = httpx.Client( verify=verify, + transport=Transport(cache=cache), cookies=cookies, timeout=timeout, headers=headers, @@ -246,6 +247,7 @@ def __setstate__(self, state): ) self._token_cache = token_cache self._cache = cache + self._verify = verify self.server_info = server_info @classmethod From 22c217b0bb16e0df03f61d5ffd30607533714be2 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Mon, 15 Jul 2024 14:47:13 -0400 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0877c9dd4..d31c4d342 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ Write the date in place of the "Unreleased" in the case a new version is release # Changelog +## Unreleased + +### Fixed +- A bug in `Context.__getstate__` caused picking to fail if applied twice. + ## v0.1.0b5 (2024-06-27) ### Added