From 78abec1651c4c3166d0eda4f9c0e43e00df57494 Mon Sep 17 00:00:00 2001 From: Ryan Marvin Date: Thu, 18 Feb 2021 18:25:25 +0300 Subject: Add comment --- jsonpatch.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jsonpatch.py b/jsonpatch.py index 14341d7..7b895b7 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -802,6 +802,10 @@ class DiffBuilder(object): new_index = self.insert(new_op) if index is not None: op = index[2] + # We can't rely on the op.key property type since PatchOperation casts + # the .key property to int and this path wrongly ends up being taken + # for numeric string dict keys while the intention is to only handle lists. + # So we do an explicit check on the item affected by the op instead. added_item = op.pointer.to_last(self.dst_doc)[0] if type(added_item) == list: for v in self.iter_from(index): -- cgit v1.2.1