From 2d67adef906b687bd4b3982416adeab13354d6c5 Mon Sep 17 00:00:00 2001 From: Alexander Shorin Date: Fri, 5 Oct 2012 00:04:34 +0400 Subject: Fix compatibility with Python 3.x --- jsonpatch.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'jsonpatch.py') diff --git a/jsonpatch.py b/jsonpatch.py index 49cca59..46649ff 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -449,8 +449,13 @@ class TestOperation(PatchOperation): def apply(self, obj): try: subobj, part = self.locate(obj, self.location) - except JsonPatchConflict, c: - raise JsonPatchTestFailed(str(c)) + except JsonPatchConflict: + exc_info = sys.exc_info() + exc = JsonPatchTestFailed(str(exc_info[1])) + if sys.version_info >= (3, 0): + raise exc.with_traceback(exc_info[2]) + else: + raise exc val = subobj[part] -- cgit v1.2.1