Skip to content

Commit

Permalink
If bytes object not decodable as UTF-8, assume binary
Browse files Browse the repository at this point in the history
Proposed solution for seperman#292
  • Loading branch information
wfaulk authored Jan 31, 2022
1 parent 7e5e995 commit b0a00f1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion deepdiff/deephash.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def prepare_string_for_hashing(obj, ignore_string_type_changes=False, ignore_str
"""
original_type = obj.__class__.__name__
if isinstance(obj, bytes):
obj = obj.decode('utf-8')
try:
obj = obj.decode('utf-8')
except UnicodeDecodeError:
return obj
if not ignore_string_type_changes:
obj = KEY_TO_VAL_STR.format(original_type, obj)
if ignore_string_case:
Expand Down

0 comments on commit b0a00f1

Please sign in to comment.