diff options
-rw-r--r-- | jsonpointer.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/jsonpointer.py b/jsonpointer.py index 050d48c..fe7914a 100644 --- a/jsonpointer.py +++ b/jsonpointer.py @@ -175,6 +175,10 @@ class JsonPointer(object): part = self.get_part(doc, part) + # type is already checked in get_part, so we assert here + # for consistency + assert type(doc) in (dict, list), "invalid document type %s" (type(doc),) + if isinstance(doc, dict): try: return doc[part] @@ -194,11 +198,6 @@ class JsonPointer(object): raise JsonPointerException("index '%s' is out of bounds" % (part, )) - else: - raise JsonPointerException("can not go beyond '%s' (type '%s')" % (part, doc.__class__)) - - - def contains(self, ptr): """" Returns True if self contains the given ptr """ return len(self.parts) > len(ptr.parts) and \ |