From 174c6badb2c6f7253589e74822bf28700f41fecc Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Thu, 21 Mar 2024 22:40:33 +0000 Subject: [PATCH] Remove circular reference check on item metadata hashing 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 --- internetarchive/item.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internetarchive/item.py b/internetarchive/item.py index 7202976b..e9201ef7 100644 --- a/internetarchive/item.py +++ b/internetarchive/item.py @@ -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):