From b641cff95b4184ed2ae209b422c872088af0da33 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sat, 25 Jun 2011 18:54:37 -0700 Subject: [PATCH] Allow non-ascii (but still latin1) in our fake byte literals --- tornado/test/httpserver_test.py | 2 +- tornado/util.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index 69ea01cd..fa48f5c2 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -110,7 +110,7 @@ class HTTPConnectionTest(AsyncHTTPTestCase, LogTrapTestCase): response = self.raw_fetch([ b("POST /multipart HTTP/1.0"), b("Content-Type: multipart/form-data; boundary=1234567890"), - u"X-Header-encoding-test: \u00e9".encode("latin1"), + b("X-Header-encoding-test: \xe9"), ], b("\r\n").join([ b("Content-Disposition: form-data; name=argument"), diff --git a/tornado/util.py b/tornado/util.py index 964a9f02..4ac59908 100644 --- a/tornado/util.py +++ b/tornado/util.py @@ -19,11 +19,11 @@ def import_object(name): # a byte literal (str in 2.x, bytes in 3.x). There's no way to do this # in a way that supports 2.5, though, so we need a function wrapper # to convert our string literals. b() should only be applied to literal -# ascii strings. Once we drop support for 2.5, we can remove this function +# latin1 strings. Once we drop support for 2.5, we can remove this function # and just use byte literals. if str is unicode: def b(s): - return s.encode('ascii') + return s.encode('latin1') bytes_type = bytes else: def b(s):