summaryrefslogtreecommitdiff
path: root/jsonpatch.py
diff options
context:
space:
mode:
authorAlanscut <wp_scut@163.com>2020-06-09 20:20:51 +0800
committerAlanscut <wp_scut@163.com>2020-06-09 20:51:46 +0800
commit86f82becdc7f69a1153f2a7400117bed09ebd8c9 (patch)
treed2624cabd8c0b756649e86b6747328e5dc197ded /jsonpatch.py
parent9e4d423c22bedad6ffc260541ae587114dfed70a (diff)
downloadpython-json-patch-86f82becdc7f69a1153f2a7400117bed09ebd8c9.tar.gz
fix #102: optimize error handling
Diffstat (limited to 'jsonpatch.py')
-rw-r--r--jsonpatch.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/jsonpatch.py b/jsonpatch.py
index ca22e34..e042ce2 100644
--- a/jsonpatch.py
+++ b/jsonpatch.py
@@ -473,6 +473,9 @@ class ReplaceOperation(PatchOperation):
if part is None:
return value
+ if part == "-":
+ raise InvalidJsonPatch("'path' with '-' can't be applied to 'replace' operation")
+
if isinstance(subobj, MutableSequence):
if part >= len(subobj) or part < 0:
raise JsonPatchConflict("can't replace outside of list")