Skip to content

Commit ec26151

Browse files
committed
Removed unrelated changes to the contains method, reverted the exception handle
1 parent 4dc8234 commit ec26151

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

jsonpointer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ def resolve(self, doc, default=_nothing):
166166

167167
try:
168168
doc = self.walk(doc, part)
169-
# Catching a broad exception to ensure the return of the default
170-
except:
169+
except JsonPointerException:
171170
if default is _nothing:
172171
raise
173172
else:
@@ -250,7 +249,7 @@ def walk(self, doc, part):
250249

251250
def contains(self, ptr):
252251
""" Returns True if self contains the given ptr """
253-
return len(self.parts) >= len(ptr.parts) and \
252+
return len(self.parts) > len(ptr.parts) and \
254253
self.parts[:len(ptr.parts)] == ptr.parts
255254

256255
@property

tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ def test_contains(self):
9696
p3 = JsonPointer("/b/c")
9797

9898
self.assertTrue(p1.contains(p2))
99-
self.assertTrue(p1.contains(p1))
10099
self.assertFalse(p1.contains(p3))
101100

102101

0 commit comments

Comments
 (0)