This will avoid an exception when trying to replace the item at the last position of an array:
ERROR: test_replace_oob_length (tests.ConflictTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/guillaume/src/jsonpatch/tests.py", line 608, in test_replace_oob_length
self.assertRaises(jsonpatch.JsonPatchConflict, jsonpatch.apply_patch, src, patch_obj)
File "/home/linuxbrew/.linuxbrew/var/pyenv/versions/3.7/lib/python3.7/unittest/case.py", line 743, in assertRaises
return context.handle('assertRaises', args, kwargs)
File "/home/linuxbrew/.linuxbrew/var/pyenv/versions/3.7/lib/python3.7/unittest/case.py", line 178, in handle
callable_obj(*args, **kwargs)
File "/home/guillaume/src/jsonpatch/jsonpatch.py", line 143, in apply_patch
return patch.apply(doc, in_place)
File "/home/guillaume/src/jsonpatch/jsonpatch.py", line 312, in apply
obj = operation.apply(obj)
File "/home/guillaume/src/jsonpatch/jsonpatch.py", line 490, in apply
subobj[part] = value
IndexError: list assignment index out of range
----------------------------------------------------------------------
This will avoid an exception when trying to replace the item at the last position of an array: