From: Ben Darnell Date: Fri, 8 Mar 2013 22:03:38 +0000 (-0500) Subject: On python 3, json_encode no longer supports byte strings as input. X-Git-Tag: v3.0.0~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a198cc40381f2b5f5806d3b6078462105a11384;p=thirdparty%2Ftornado.git On python 3, json_encode no longer supports byte strings as input. This matches the behavior of the underlying json library. recursive_unicode was more expensive than the actual json encoding for complex structures, and was useless on python 2. --- diff --git a/tornado/escape.py b/tornado/escape.py index 6d72532d2..e565ff538 100644 --- a/tornado/escape.py +++ b/tornado/escape.py @@ -28,9 +28,9 @@ import sys from tornado.util import bytes_type, unicode_type, basestring_type, u try: - from urllib.parse import parse_qs # py3 + from urllib.parse import parse_qs as _parse_qs # py3 except ImportError: - from urlparse import parse_qs # Python 2.6+ + from urlparse import parse_qs as _parse_qs # Python 2.6+ try: import htmlentitydefs # py2 @@ -72,7 +72,7 @@ def json_encode(value): # the javscript. Some json libraries do this escaping by default, # although python's standard library does not, so we do it here. # http://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped - return json.dumps(recursive_unicode(value)).replace("