@@ -367,7 +367,7 @@ def _get_operation(self, operation):
367
367
raise JsonPatchException ("Operation must be a string" )
368
368
369
369
if op not in self .operations :
370
- raise JsonPatchException ("Unknown operation '%s'" % op )
370
+ raise JsonPatchException ("Unknown operation {0!r}" . format ( op ) )
371
371
372
372
cls = self .operations [op ]
373
373
return cls (operation )
@@ -434,7 +434,7 @@ def apply(self, obj):
434
434
subobj [part ] = value
435
435
436
436
else :
437
- raise TypeError ("invalid document type %s" % (type (subobj ), ))
437
+ raise TypeError ("invalid document type {0}" . format (type (subobj )))
438
438
439
439
return obj
440
440
@@ -455,11 +455,10 @@ def apply(self, obj):
455
455
456
456
elif isinstance (subobj , dict ):
457
457
if not part in subobj :
458
- raise JsonPatchConflict ("can't replace non-existent object '%s'"
459
- % part )
460
-
458
+ msg = "can't replace non-existent object '{0}'" .format (part )
459
+ raise JsonPatchConflict (msg )
461
460
else :
462
- raise TypeError ("invalid document type %s" % (type (subobj ), ))
461
+ raise TypeError ("invalid document type {0}" . format (type (subobj )))
463
462
464
463
subobj [part ] = value
465
464
return obj
@@ -506,9 +505,9 @@ def apply(self, obj):
506
505
if 'value' in self .operation :
507
506
value = self .operation ['value' ]
508
507
if val != value :
509
- raise JsonPatchTestFailed (
510
- '%s is not equal to tested value %s (types %s and %s)'
511
- % ( val , value , type ( val ) , type (value )))
508
+ msg = '{0} ({1}) is not equal to tested value {2} ({3})'
509
+ raise JsonPatchTestFailed ( msg . format ( val , type ( val ),
510
+ value , type (value )))
512
511
513
512
return obj
514
513
0 commit comments