diff options
Diffstat (limited to 'Lib/json/encoder.py')
-rw-r--r-- | Lib/json/encoder.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py index 0513838..26e9eb2 100644 --- a/Lib/json/encoder.py +++ b/Lib/json/encoder.py @@ -7,6 +7,10 @@ try: except ImportError: c_encode_basestring_ascii = None try: + from _json import encode_basestring as c_encode_basestring +except ImportError: + c_encode_basestring = None +try: from _json import make_encoder as c_make_encoder except ImportError: c_make_encoder = None @@ -30,7 +34,7 @@ for i in range(0x20): INFINITY = float('inf') FLOAT_REPR = repr -def encode_basestring(s): +def py_encode_basestring(s): """Return a JSON representation of a Python string """ @@ -39,6 +43,9 @@ def encode_basestring(s): return '"' + ESCAPE.sub(replace, s) + '"' +encode_basestring = (c_encode_basestring or py_encode_basestring) + + def py_encode_basestring_ascii(s): """Return an ASCII-only JSON representation of a Python string |