Changeset - 3ae42e10b665
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2012-09-06 11:32:36
marcin@python-works.com
fix ext-json extension issue when exception is raised for non-serializable objects
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/ext_json.py
Show inline comments
 
@@ -83,25 +83,25 @@ except ImportError:
 

	
 
try:
 
    # simplejson not found try out regular json module
 
    import json
 

	
 
    # extended JSON encoder for json
 
    class ExtendedEncoder(json.JSONEncoder):
 
        def default(self, obj):
 
            try:
 
                return _obj_dump(obj)
 
            except NotImplementedError:
 
                pass
 
            return json.JSONEncoder.default(self, obj)
 
            raise TypeError("%r is not JSON serializable" % (obj,))
 
    # monkey-patch JSON encoder to use extended version
 
    json.dumps = functools.partial(json.dumps, cls=ExtendedEncoder)
 
    json.dump = functools.partial(json.dump, cls=ExtendedEncoder)
 

	
 
except ImportError:
 
    json = None
 

	
 
stdlib = json
 

	
 
# set all available json modules
 
if simplejson:
 
    json = simplejson
0 comments (0 inline, 0 general)