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

fix: use deterministic comparison ordering #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 4 additions & 5 deletions jsonpatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,18 +859,17 @@ def _item_replaced(self, path, key, item):
}, pointer_cls=self.pointer_cls))

def _compare_dicts(self, path, src, dst):
src_keys = set(src.keys())
dst_keys = set(dst.keys())
added_keys = dst_keys - src_keys
removed_keys = src_keys - dst_keys
added_keys = [key for key in dst.keys() if key not in src.keys()]
removed_keys = [key for key in src.keys() if key not in dst.keys()]
intersection = [key for key in src.keys() if key in dst.keys()]

for key in removed_keys:
self._item_removed(path, str(key), src[key])

for key in added_keys:
self._item_added(path, str(key), dst[key])

for key in src_keys & dst_keys:
for key in intersection:
self._compare_values(path, key, src[key], dst[key])

def _compare_lists(self, path, src, dst):
Expand Down