Skip to content

Commit 86b82bf

Browse files
authored
Merge pull request #91 from muneikh/fix-pointer-join-interruptions
2 parents f2641f0 + bd83197 commit 86b82bf

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎jsonpointer.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def join(self, suffix):
307307
suffix_parts = suffix
308308
try:
309309
return self.__class__.from_parts(chain(self.parts, suffix_parts))
310-
except: # noqa E722
310+
except Exception:
311311
raise JsonPointerException("Invalid suffix")
312312

313313
def __truediv__(self, suffix):

‎tests.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,19 @@ def test_join_magic(self):
196196
ptr12e = self.ptr1 / ["a", "b"]
197197
self.assertEqual(ptr12e.path, "/a/b/c/a/b")
198198

199+
def test_join_preserves_control_flow_exceptions(self):
200+
for exception_type in (KeyboardInterrupt, SystemExit, GeneratorExit):
201+
with self.subTest(exception_type=exception_type):
202+
error = exception_type()
203+
204+
def parts():
205+
yield 'valid'
206+
raise error
207+
208+
with self.assertRaises(exception_type) as caught:
209+
self.ptr1.join(parts())
210+
self.assertIs(caught.exception, error)
211+
199212
def test_join_subclass(self):
200213
class Pointer(JsonPointer):
201214
pass

0 commit comments

Comments
 (0)