diff options
author | Stefan Kögl <stefan@skoegl.net> | 2013-07-12 19:40:27 +0200 |
---|---|---|
committer | Stefan Kögl <stefan@skoegl.net> | 2013-07-12 19:40:27 +0200 |
commit | b369c2372b5cd15e55933919d306cbae93da8c27 (patch) | |
tree | f99a0d8842e2b2bb00d24e56e843c7d21cdf1fc3 | |
parent | a7add82366eaed40c72c5ce8eb35dad40f833319 (diff) | |
download | python-json-patch-b369c2372b5cd15e55933919d306cbae93da8c27.tar.gz |
refactor type check
-rw-r--r-- | jsonpatch.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/jsonpatch.py b/jsonpatch.py index ae2fbef..c9dcd3c 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -366,6 +366,11 @@ class AddOperation(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 isinstance(subobj, list): if part == '-': @@ -385,10 +390,6 @@ class AddOperation(PatchOperation): else: subobj[part] = value - else: - raise JsonPatchConflict("can't add to type '%s'" - "" % subobj.__class__.__name__) - return obj |