diff options
-rw-r--r-- | index.rst | 2 | ||||
-rw-r--r-- | simplejson/__init__.py | 2 | ||||
-rw-r--r-- | simplejson/encoder.py | 9 | ||||
-rw-r--r-- | simplejson/tool.py | 2 |
4 files changed, 8 insertions, 7 deletions
@@ -85,7 +85,7 @@ Specializing JSON object encoding:: >>> def encode_complex(obj): ... if isinstance(obj, complex): ... return [obj.real, obj.imag] - ... raise TypeError("%r is not JSON serializable" % (o,)) + ... raise TypeError(repr(o) + " is not JSON serializable") ... >>> json.dumps(2 + 1j, default=encode_complex) '[2.0, 1.0]' diff --git a/simplejson/__init__.py b/simplejson/__init__.py index 8b4f458..d5b4d39 100644 --- a/simplejson/__init__.py +++ b/simplejson/__init__.py @@ -78,7 +78,7 @@ Specializing JSON object encoding:: >>> def encode_complex(obj): ... if isinstance(obj, complex): ... return [obj.real, obj.imag] - ... raise TypeError("%r is not JSON serializable" % (o,)) + ... raise TypeError(repr(o) + " is not JSON serializable") ... >>> json.dumps(2 + 1j, default=encode_complex) '[2.0, 1.0]' diff --git a/simplejson/encoder.py b/simplejson/encoder.py index 056847b..d13b03d 100644 --- a/simplejson/encoder.py +++ b/simplejson/encoder.py @@ -171,7 +171,7 @@ class JSONEncoder(object): return JSONEncoder.default(self, o) """ - raise TypeError("%r is not JSON serializable" % (o,)) + raise TypeError(repr(o) + " is not JSON serializable") def encode(self, o): """Return a JSON string representation of a Python data structure. @@ -237,8 +237,9 @@ class JSONEncoder(object): return _repr(o) if not allow_nan: - raise ValueError("Out of range float values are not JSON compliant: %r" - % (o,)) + raise ValueError( + "Out of range float values are not JSON compliant: " + + repr(o)) return text @@ -367,7 +368,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, _key_separ elif _skipkeys: continue else: - raise TypeError("key %r is not a string" % (key,)) + raise TypeError("key " + repr(key) + " is not a string") if first: first = False else: diff --git a/simplejson/tool.py b/simplejson/tool.py index 0ba20bb..9044331 100644 --- a/simplejson/tool.py +++ b/simplejson/tool.py @@ -24,7 +24,7 @@ def main(): infile = open(sys.argv[1], 'rb') outfile = open(sys.argv[2], 'wb') else: - raise SystemExit("%s [infile [outfile]]" % (sys.argv[0],)) + raise SystemExit(sys.argv[0] + " [infile [outfile]]") try: obj = simplejson.load(infile) except ValueError, e: |