summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kögl <stefan@skoegl.net>2013-07-12 19:47:13 +0200
committerStefan Kögl <stefan@skoegl.net>2013-07-12 19:47:13 +0200
commit78e865ac31689bc95f318722c793dab26cb8b560 (patch)
treeee1fb6475ce54da9cfa2cd1284b7033d080f8d8f
parent7d0e0faeedbff07a597409be4e5607547944242b (diff)
downloadpython-json-patch-78e865ac31689bc95f318722c793dab26cb8b560.tar.gz
refactor tpye check
-rw-r--r--jsonpatch.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/jsonpatch.py b/jsonpatch.py
index c9dcd3c..bff1d50 100644
--- a/jsonpatch.py
+++ b/jsonpatch.py
@@ -400,6 +400,11 @@ class ReplaceOperation(PatchOperation):
value = self.operation["value"]
subobj, part = self.pointer.to_last(obj)
+ # type is already checked in to_last(), so we assert here
+ # for consistency
+ assert isinstance(subobj, list) or isinstance(subobj, dict), \
+ "invalid document type %s" (type(doc),)
+
if part is None:
return value
@@ -412,10 +417,6 @@ class ReplaceOperation(PatchOperation):
raise JsonPatchConflict("can't replace non-existant object '%s'"
"" % part)
- else:
- raise JsonPatchConflict("can't replace in type '%s'"
- "" % subobj.__class__.__name__)
-
subobj[part] = value
return obj