summaryrefslogtreecommitdiff
path: root/sphinx/util/jsonimpl.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/util/jsonimpl.py')
-rw-r--r--sphinx/util/jsonimpl.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/sphinx/util/jsonimpl.py b/sphinx/util/jsonimpl.py
index d5a4f8293..ecb0b791a 100644
--- a/sphinx/util/jsonimpl.py
+++ b/sphinx/util/jsonimpl.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
sphinx.util.jsonimpl
~~~~~~~~~~~~~~~~~~~~
@@ -10,9 +9,7 @@
"""
import json
-
-from six import text_type
-from six.moves import UserString
+from collections import UserString
if False:
# For type annotation
@@ -22,10 +19,10 @@ if False:
class SphinxJSONEncoder(json.JSONEncoder):
"""JSONEncoder subclass that forces translation proxies."""
def default(self, obj):
- # type: (Any) -> unicode
+ # type: (Any) -> str
if isinstance(obj, UserString):
- return text_type(obj)
- return json.JSONEncoder.default(self, obj)
+ return str(obj)
+ return super().default(obj)
def dump(obj, fp, *args, **kwds):
@@ -35,7 +32,7 @@ def dump(obj, fp, *args, **kwds):
def dumps(obj, *args, **kwds):
- # type: (Any, Any, Any) -> unicode
+ # type: (Any, Any, Any) -> str
kwds['cls'] = SphinxJSONEncoder
return json.dumps(obj, *args, **kwds)