Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions deepdiff/deephash.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
from deepdiff.base import Base
logger = logging.getLogger(__name__)

UNPROCESSED_KEY = 'unprocessed'
UNPROCESSED_KEY = object()

RESERVED_DICT_KEYS = {UNPROCESSED_KEY}
EMPTY_FROZENSET = frozenset()

INDEX_VS_ATTRIBUTE = ('[%s]', '.%s')
Expand Down Expand Up @@ -185,7 +184,7 @@ def _getitem(hashes, obj, extract_index=0):
except KeyError:
raise KeyError(HASH_LOOKUP_ERR_MSG.format(obj)) from None

if isinstance(obj, strings) and obj in RESERVED_DICT_KEYS:
if obj is UNPROCESSED_KEY:
extract_index = None

return result_n_count if extract_index is None else result_n_count[extract_index]
Expand Down Expand Up @@ -229,7 +228,7 @@ def _get_objects_to_hashes_dict(self, extract_index=0):
"""
result = dict_()
for key, value in self.hashes.items():
if key in RESERVED_DICT_KEYS:
if key is UNPROCESSED_KEY:
result[key] = value
else:
result[key] = value[extract_index]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __repr__(self):
t1 = Bad()

result = DeepHash(t1)
expected_result = {t1: unprocessed, 'unprocessed': [t1]}
expected_result = {t1: unprocessed, UNPROCESSED_KEY: [t1]}
assert expected_result == result

def test_built_in_hash_not_sensitive_to_bytecode_vs_unicode(self):
Expand Down Expand Up @@ -407,7 +407,7 @@ def __str__(self):
t1 = Bad()

result = DeepHashPrep(t1)
expected_result = {t1: unprocessed, 'unprocessed': [t1]}
expected_result = {t1: unprocessed, UNPROCESSED_KEY: [t1]}
assert expected_result == result

class Burrito:
Expand Down