diff options
author | Stefan Kögl <stefan@skoegl.net> | 2013-07-12 19:47:13 +0200 |
---|---|---|
committer | Stefan Kögl <stefan@skoegl.net> | 2013-07-12 19:47:13 +0200 |
commit | 78e865ac31689bc95f318722c793dab26cb8b560 (patch) | |
tree | ee1fb6475ce54da9cfa2cd1284b7033d080f8d8f | |
parent | 7d0e0faeedbff07a597409be4e5607547944242b (diff) | |
download | python-json-patch-78e865ac31689bc95f318722c793dab26cb8b560.tar.gz |
refactor tpye check
-rw-r--r-- | jsonpatch.py | 9 |
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 |