]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Make escape.json_decode accept either unicode or (utf8) bytes
authorBen Darnell <ben@bendarnell.com>
Fri, 25 Feb 2011 00:44:54 +0000 (16:44 -0800)
committerBen Darnell <ben@bendarnell.com>
Fri, 25 Feb 2011 00:44:54 +0000 (16:44 -0800)
tornado/escape.py
tornado/test/web_test.py

index 752c90951aafb815f2ed130276f30275932fdaff..ee4ffb68c01acdf7a3b8bccd257d339aa1a2ba46 100644 (file)
@@ -74,7 +74,7 @@ def json_encode(value):
 
 def json_decode(value):
     """Returns Python objects for the given JSON string."""
-    return _json_decode(value)
+    return _json_decode(_unicode(value))
 
 
 def squeeze(value):
index 707ab01e088931e73aa64f16dbb3bb06554ab6cd..8941332d027b44603ec2982a572bd7978d1c4759 100644 (file)
@@ -128,8 +128,8 @@ class RequestEncodingTest(AsyncHTTPTestCase, LogTrapTestCase):
 
     def test_question_mark(self):
         # Ensure that url-encoded question marks are handled properly
-        self.assertEqual(json_decode(self.fetch('/%3F').body.decode('utf8')),
+        self.assertEqual(json_decode(self.fetch('/%3F').body),
                          dict(path='?', args={}))
-        self.assertEqual(json_decode(self.fetch('/%3F?%3F=%3F').body.decode('utf8')),
+        self.assertEqual(json_decode(self.fetch('/%3F?%3F=%3F').body),
                          dict(path='?', args={'?': ['?']}))