Allow non-ascii (but still latin1) in our fake byte literals

This commit is contained in:
Ben Darnell 2011-06-25 18:54:37 -07:00
parent 84acb204a6
commit b641cff95b
2 changed files with 3 additions and 3 deletions

View File

@ -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"),

View File

@ -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):