/usr/lib/python2.7/dist-packages/sphinx/util/jsonimpl.py is in python-sphinx 1.6.7-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # -*- coding: utf-8 -*-
"""
sphinx.util.jsonimpl
~~~~~~~~~~~~~~~~~~~~
JSON serializer implementation wrapper.
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import json
from six import text_type
from six.moves import UserString
if False:
# For type annotation
from typing import Any, IO # NOQA
class SphinxJSONEncoder(json.JSONEncoder):
"""JSONEncoder subclass that forces translation proxies."""
def default(self, obj):
# type: (Any) -> unicode
if isinstance(obj, UserString):
return text_type(obj)
return json.JSONEncoder.default(self, obj)
def dump(obj, fp, *args, **kwds):
# type: (Any, IO, Any, Any) -> None
kwds['cls'] = SphinxJSONEncoder
json.dump(obj, fp, *args, **kwds)
def dumps(obj, *args, **kwds):
# type: (Any, Any, Any) -> unicode
kwds['cls'] = SphinxJSONEncoder
return json.dumps(obj, *args, **kwds)
def load(*args, **kwds):
# type: (Any, Any) -> Any
return json.load(*args, **kwds)
def loads(*args, **kwds):
# type: (Any, Any) -> Any
return json.loads(*args, **kwds)
|