Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when comparing non-text byte strings with ignore_order=True #292

Closed
wfaulk opened this issue Jan 26, 2022 · 2 comments
Closed

error when comparing non-text byte strings with ignore_order=True #292

wfaulk opened this issue Jan 26, 2022 · 2 comments
Assignees
Labels

Comments

@wfaulk
Copy link

wfaulk commented Jan 26, 2022

Describe the bug
If a data structure contains a bytes object and that object is not valid UTF-8, DeepDiff complainsCan not produce a hash for <object> and ignores the object if ignore_order=True is set

To Reproduce

from deepdiff import DeepDiff

t1 = [ b'\xc3\xb1' ]
t2 = [ b'\xc3\x28' ]

print(DeepDiff(t1,t2))
print(DeepDiff(t1,t2, ignore_order=True))

This produces:

{'values_changed': {'root[0]': {'new_value': b'\xc3(', 'old_value': b'\xc3\xb1'}}}
Can not produce a hash for root.Not counting this object.
 'utf-8' codec can't decode byte 0xc3 in position 0: invalid continuation byte
Can not produce a hash for iterable root. 'utf-8' codec can't decode byte 0xc3 in position 0: invalid continuation byte
{'iterable_item_removed': {'root[0]': b'\xc3\xb1'}}

Expected behavior

{'values_changed': {'root[0]': {'new_value': b'\xc3(', 'old_value': b'\xc3\xb1'}}}
{'values_changed': {'root[0]': {'new_value': b'\xc3(', 'old_value': b'\xc3\xb1'}}}

OS, DeepDiff version and Python version (please complete the following information):

  • OS: MacOS 11.6.1
  • Python: 3.9.9
  • DeepDiff: 5.7.0
@seperman
Copy link
Owner

@wfaulk
Cool, I will look into DeepHash and handling bytes. Thanks for reporting the issue. Btw if you are interested and have time, PR's are always very welcome!
Thanks

@seperman seperman added the bug label Jan 29, 2022
wfaulk added a commit to wfaulk/deepdiff that referenced this issue Jan 31, 2022
@seperman seperman self-assigned this Apr 9, 2022
@seperman seperman mentioned this issue Apr 10, 2022
7 tasks
@seperman
Copy link
Owner

@wfaulk DeepDiff 5.8.0 is published and this issues is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants