diff options
author | Alexander Shorin <kxepal@apache.org> | 2013-11-12 08:21:46 +0400 |
---|---|---|
committer | Alexander Shorin <kxepal@apache.org> | 2013-11-12 08:21:46 +0400 |
commit | edf8700771dd69325f4bd4b7d072f26149ff1c41 (patch) | |
tree | 044efde4b373061ff2b009a19c2b8e783e6c8363 /jsonpatch.py | |
parent | 3ab6c5a251110fcf06d3e740e7658fa089c9e1eb (diff) | |
download | python-json-patch-edf8700771dd69325f4bd4b7d072f26149ff1c41.tar.gz |
Use new string formatting syntax
Python 2.5 support was dropped long ago to care about
Diffstat (limited to 'jsonpatch.py')
-rw-r--r-- | jsonpatch.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/jsonpatch.py b/jsonpatch.py index 0a0aa04..074fcb9 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -367,7 +367,7 @@ class JsonPatch(object): raise JsonPatchException("Operation must be a string") if op not in self.operations: - raise JsonPatchException("Unknown operation '%s'" % op) + raise JsonPatchException("Unknown operation {0!r}".format(op)) cls = self.operations[op] return cls(operation) @@ -434,7 +434,7 @@ class AddOperation(PatchOperation): subobj[part] = value else: - raise TypeError("invalid document type %s" % (type(subobj),)) + raise TypeError("invalid document type {0}".format(type(subobj))) return obj @@ -455,11 +455,10 @@ class ReplaceOperation(PatchOperation): elif isinstance(subobj, dict): if not part in subobj: - raise JsonPatchConflict("can't replace non-existent object '%s'" - % part) - + msg = "can't replace non-existent object '{0}'".format(part) + raise JsonPatchConflict(msg) else: - raise TypeError("invalid document type %s" % (type(subobj),)) + raise TypeError("invalid document type {0}".format(type(subobj))) subobj[part] = value return obj @@ -506,9 +505,9 @@ class TestOperation(PatchOperation): if 'value' in self.operation: value = self.operation['value'] if val != value: - raise JsonPatchTestFailed( - '%s is not equal to tested value %s (types %s and %s)' - % (val, value, type(val), type(value))) + msg = '{0} ({1}) is not equal to tested value {2} ({3})' + raise JsonPatchTestFailed(msg.format(val, type(val), + value, type(value))) return obj |