]> granicus.if.org Git - python/commitdiff
Issue #26623: TypeError message for JSON unserializible object now contains
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 10 Apr 2016 12:46:30 +0000 (15:46 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 10 Apr 2016 12:46:30 +0000 (15:46 +0300)
object's type name, not object's representation.
Based on patch by Mahmoud Lababidi.

Lib/json/encoder.py

index d596489f42d3856db96f507e1f04d410d154b58e..0772bbc06b9e619dff91dbd45a1e41219eb3aece 100644 (file)
@@ -176,7 +176,8 @@ class JSONEncoder(object):
                 return JSONEncoder.default(self, o)
 
         """
-        raise TypeError(repr(o) + " is not JSON serializable")
+        raise TypeError("Object of type '%s' is not JSON serializable" %
+                        o.__class__.__name__)
 
     def encode(self, o):
         """Return a JSON string representation of a Python data structure.