Skip to content

Commit

Permalink
Remove circular reference check on item metadata hashing
Browse files Browse the repository at this point in the history
Unless someone actively tries to break things by passing a crafted object, it should not generally be possible for there to be circular references. In addition, if someone were to do that, things would break in many other places, e.g. `MetadataPreparedRequest`, anyway. Guarding against a crash on hashing in that specific unusual scenario does not seem worthwhile and breaks when ujson is in use.

Fixes #540
  • Loading branch information
JustAnotherArchivist committed Mar 21, 2024
1 parent 29272b1 commit 174c6ba
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internetarchive/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ def __hash__(self) -> int:
without_excluded_keys = {
k: v for k, v in self.item_metadata.items()
if k not in self.EXCLUDED_ITEM_METADATA_KEYS}
return hash(json.dumps(without_excluded_keys,
sort_keys=True, check_circular=False)) # type: ignore
return hash(json.dumps(without_excluded_keys, sort_keys=True)) # type: ignore


class Item(BaseItem):
Expand Down

0 comments on commit 174c6ba

Please sign in to comment.