Skip to content

Commit 987477d

Browse files
committed
fix: don't transform_href in __getstate__ (#1337)
1 parent 858f43f commit 987477d

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
7+
- Don't transform hrefs in `Item.__getstate__` ([#1337](https://github.com/stac-utils/pystac/pull/1337))
8+
59
## [v1.10.0] - 2024-03-28
610

711
### Added

pystac/item.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,12 @@ def __getstate__(self) -> dict[str, Any]:
177177
d = self.__dict__.copy()
178178

179179
d["links"] = [
180-
link.to_dict() if link.get_href() else link for link in d["links"]
180+
(
181+
link.to_dict(transform_href=False)
182+
if link.get_href(transform_href=False)
183+
else link
184+
)
185+
for link in d["links"]
181186
]
182187

183188
return d

tests/test_item.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import copy
34
import json
45
import os
56
import pickle
@@ -682,3 +683,12 @@ def test_pickle_with_only_href_links(item: Item) -> None:
682683
assert original.media_type == new.media_type
683684
assert str(original.owner) == str(new.owner)
684685
assert str(original.target) == str(new.target)
686+
687+
688+
def test_copy_with_unresolveable_root(item: Item) -> None:
689+
item.add_link(
690+
pystac.Link(
691+
"root", "s3://naip-visualization/this-is-a-non-existent-catalog.json"
692+
)
693+
)
694+
copy.deepcopy(item)

0 commit comments

Comments
 (0)