From: Ben Darnell Date: Sat, 19 Jan 2013 18:29:10 +0000 (-0500) Subject: Remove the remaining traces of tornado.util.b. X-Git-Tag: v3.0.0~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=925302600f9ba74dc7e7df8ee0d29e293cc7bde8;p=thirdparty%2Ftornado.git Remove the remaining traces of tornado.util.b. --- diff --git a/tornado/auth.py b/tornado/auth.py index 600b5c87f..6fa65442c 100644 --- a/tornado/auth.py +++ b/tornado/auth.py @@ -58,7 +58,7 @@ from tornado import httpclient from tornado import escape from tornado.httputil import url_concat from tornado.log import gen_log -from tornado.util import bytes_type, b, u, unicode_type +from tornado.util import bytes_type, u, unicode_type try: import urlparse # py2 diff --git a/tornado/httpserver.py b/tornado/httpserver.py index ba6ab6224..ae063fedd 100644 --- a/tornado/httpserver.py +++ b/tornado/httpserver.py @@ -35,7 +35,7 @@ from tornado import iostream from tornado.log import gen_log from tornado.netutil import TCPServer from tornado import stack_context -from tornado.util import b, bytes_type +from tornado.util import bytes_type try: import ssl # Python 2.6+ diff --git a/tornado/httputil.py b/tornado/httputil.py index 110cc208a..e01550626 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -23,7 +23,7 @@ import re from tornado.escape import native_str, parse_qs_bytes, utf8 from tornado.log import gen_log -from tornado.util import b, ObjectDict +from tornado.util import ObjectDict try: from httplib import responses # py2 @@ -57,7 +57,7 @@ class HTTPHeaders(dict): >>> for (k,v) in sorted(h.get_all()): ... print('%s: %s' % (k,v)) - ... + ... Content-Type: text/html Set-Cookie: A=B Set-Cookie: C=D diff --git a/tornado/iostream.py b/tornado/iostream.py index f7a16f000..4aca7b11f 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -37,7 +37,7 @@ import re from tornado import ioloop from tornado.log import gen_log, app_log from tornado import stack_context -from tornado.util import b, bytes_type +from tornado.util import bytes_type try: import ssl # Python 2.6+ diff --git a/tornado/platform/common.py b/tornado/platform/common.py index fda5beeb9..e8ab61f89 100644 --- a/tornado/platform/common.py +++ b/tornado/platform/common.py @@ -5,7 +5,6 @@ import errno import socket from tornado.platform import interface -from tornado.util import b class Waker(interface.Waker): diff --git a/tornado/platform/posix.py b/tornado/platform/posix.py index 2a7f42223..41a5794c6 100644 --- a/tornado/platform/posix.py +++ b/tornado/platform/posix.py @@ -22,7 +22,6 @@ import fcntl import os from tornado.platform import interface -from tornado.util import b def set_close_exec(fd): diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index 7d1b8912b..5b3c90287 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -8,7 +8,7 @@ from tornado.iostream import IOStream, SSLIOStream from tornado.netutil import Resolver from tornado.log import gen_log from tornado import stack_context -from tornado.util import b, GzipDecompressor +from tornado.util import GzipDecompressor import base64 import collections diff --git a/tornado/test/auth_test.py b/tornado/test/auth_test.py index 969deb850..d6b429e06 100644 --- a/tornado/test/auth_test.py +++ b/tornado/test/auth_test.py @@ -8,7 +8,7 @@ from __future__ import absolute_import, division, print_function, with_statement from tornado.auth import OpenIdMixin, OAuthMixin, OAuth2Mixin, TwitterMixin from tornado.escape import json_decode from tornado.testing import AsyncHTTPTestCase -from tornado.util import b, u +from tornado.util import u from tornado.web import RequestHandler, Application, asynchronous diff --git a/tornado/test/concurrent_test.py b/tornado/test/concurrent_test.py index f6a8e268d..d9654085b 100644 --- a/tornado/test/concurrent_test.py +++ b/tornado/test/concurrent_test.py @@ -25,7 +25,6 @@ from tornado import gen from tornado.iostream import IOStream from tornado.netutil import TCPServer from tornado.testing import AsyncTestCase, LogTrapTestCase, get_unused_port -from tornado.util import b class CapServer(TCPServer): def handle_stream(self, stream, address): diff --git a/tornado/test/escape_test.py b/tornado/test/escape_test.py index 75a82092a..d3a47b5fc 100644 --- a/tornado/test/escape_test.py +++ b/tornado/test/escape_test.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function, with_statement import tornado.escape from tornado.escape import utf8, xhtml_escape, xhtml_unescape, url_escape, url_unescape, to_unicode, json_decode, json_encode -from tornado.util import b, u, unicode_type +from tornado.util import u, unicode_type from tornado.test.util import unittest linkify_tests = [ diff --git a/tornado/test/gen_test.py b/tornado/test/gen_test.py index d36eb9797..7c97ba14d 100644 --- a/tornado/test/gen_test.py +++ b/tornado/test/gen_test.py @@ -4,7 +4,6 @@ from tornado.escape import url_escape from tornado.httpclient import AsyncHTTPClient from tornado.log import app_log from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, ExpectLog -from tornado.util import b from tornado.web import Application, RequestHandler, asynchronous from tornado import gen diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index dc5a932e5..d4e0579a7 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -16,7 +16,7 @@ from tornado import netutil from tornado.stack_context import ExceptionStackContext, NullContext from tornado.testing import AsyncHTTPTestCase, bind_unused_port from tornado.test.util import unittest -from tornado.util import b, u, bytes_type +from tornado.util import u, bytes_type from tornado.web import Application, RequestHandler, url @@ -134,7 +134,7 @@ class HTTPClientCommonTestCase(AsyncHTTPTestCase): sock, port = bind_unused_port() with closing(sock): def write_response(stream, request_data): - stream.write(b("""\ + stream.write(b"""\ HTTP/1.1 200 OK Transfer-Encoding: chunked @@ -144,7 +144,7 @@ Transfer-Encoding: chunked 2 0 -""").replace(b"\n", b"\r\n"), callback=stream.close) +""".replace(b"\n", b"\r\n"), callback=stream.close) def accept_callback(conn, address): # fake an HTTP server using chunked encoding where the final chunks diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index f0c8cfb74..b16e4c6a8 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -11,7 +11,7 @@ from tornado.log import gen_log from tornado.simple_httpclient import SimpleAsyncHTTPClient from tornado.testing import AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCase, ExpectLog from tornado.test.util import unittest -from tornado.util import b, u, bytes_type +from tornado.util import u, bytes_type from tornado.web import Application, RequestHandler, asynchronous import datetime import os diff --git a/tornado/test/httputil_test.py b/tornado/test/httputil_test.py index 182b0c32c..db8b615f8 100644 --- a/tornado/test/httputil_test.py +++ b/tornado/test/httputil_test.py @@ -7,7 +7,6 @@ from tornado.escape import utf8 from tornado.log import gen_log from tornado.testing import ExpectLog from tornado.test.util import unittest -from tornado.util import b import logging @@ -65,12 +64,12 @@ class TestUrlConcat(unittest.TestCase): class MultipartFormDataTest(unittest.TestCase): def test_file_upload(self): - data = b("""\ + data = b"""\ --1234 Content-Disposition: form-data; name="files"; filename="ab.txt" Foo ---1234--""").replace(b"\n", b"\r\n") +--1234--""".replace(b"\n", b"\r\n") args = {} files = {} parse_multipart_form_data(b"1234", data, args, files) @@ -80,12 +79,12 @@ Foo def test_unquoted_names(self): # quotes are optional unless special characters are present - data = b("""\ + data = b"""\ --1234 Content-Disposition: form-data; name=files; filename=ab.txt Foo ---1234--""").replace(b"\n", b"\r\n") +--1234--""".replace(b"\n", b"\r\n") args = {} files = {} parse_multipart_form_data(b"1234", data, args, files) @@ -119,12 +118,12 @@ Foo self.assertEqual(file["body"], b"Foo") def test_boundary_starts_and_ends_with_quotes(self): - data = b('''\ + data = b'''\ --1234 Content-Disposition: form-data; name="files"; filename="ab.txt" Foo ---1234--''').replace(b"\n", b"\r\n") +--1234--'''.replace(b"\n", b"\r\n") args = {} files = {} parse_multipart_form_data(b'"1234"', data, args, files) @@ -133,11 +132,11 @@ Foo self.assertEqual(file["body"], b"Foo") def test_missing_headers(self): - data = b('''\ + data = b'''\ --1234 Foo ---1234--''').replace(b"\n", b"\r\n") +--1234--'''.replace(b"\n", b"\r\n") args = {} files = {} with ExpectLog(gen_log, "multipart/form-data missing headers"): @@ -145,12 +144,12 @@ Foo self.assertEqual(files, {}) def test_invalid_content_disposition(self): - data = b('''\ + data = b'''\ --1234 Content-Disposition: invalid; name="files"; filename="ab.txt" Foo ---1234--''').replace(b"\n", b"\r\n") +--1234--'''.replace(b"\n", b"\r\n") args = {} files = {} with ExpectLog(gen_log, "Invalid multipart/form-data"): @@ -158,11 +157,11 @@ Foo self.assertEqual(files, {}) def test_line_does_not_end_with_correct_line_break(self): - data = b('''\ + data = b'''\ --1234 Content-Disposition: form-data; name="files"; filename="ab.txt" -Foo--1234--''').replace(b"\n", b"\r\n") +Foo--1234--'''.replace(b"\n", b"\r\n") args = {} files = {} with ExpectLog(gen_log, "Invalid multipart/form-data"): @@ -170,12 +169,12 @@ Foo--1234--''').replace(b"\n", b"\r\n") self.assertEqual(files, {}) def test_content_disposition_header_without_name_parameter(self): - data = b("""\ + data = b"""\ --1234 Content-Disposition: form-data; filename="ab.txt" Foo ---1234--""").replace(b"\n", b"\r\n") +--1234--""".replace(b"\n", b"\r\n") args = {} files = {} with ExpectLog(gen_log, "multipart/form-data value missing name"): @@ -186,13 +185,13 @@ Foo # The spec requires that data after the final boundary be ignored. # http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html # In practice, some libraries include an extra CRLF after the boundary. - data = b("""\ + data = b"""\ --1234 Content-Disposition: form-data; name="files"; filename="ab.txt" Foo --1234-- -""").replace(b"\n", b"\r\n") +""".replace(b"\n", b"\r\n") args = {} files = {} parse_multipart_form_data(b"1234", data, args, files) diff --git a/tornado/test/iostream_test.py b/tornado/test/iostream_test.py index 048008fab..da0930349 100644 --- a/tornado/test/iostream_test.py +++ b/tornado/test/iostream_test.py @@ -6,7 +6,6 @@ from tornado.log import gen_log, app_log from tornado.stack_context import NullContext from tornado.testing import AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCase, bind_unused_port, ExpectLog from tornado.test.util import unittest, skipIfNonUnix -from tornado.util import b from tornado.web import RequestHandler, Application import errno import logging diff --git a/tornado/test/locale_test.py b/tornado/test/locale_test.py index 58f5b5e95..043f5d278 100644 --- a/tornado/test/locale_test.py +++ b/tornado/test/locale_test.py @@ -4,7 +4,7 @@ import os import tornado.locale from tornado.escape import utf8 from tornado.test.util import unittest -from tornado.util import b, u, unicode_type +from tornado.util import u, unicode_type class TranslationLoaderTest(unittest.TestCase): diff --git a/tornado/test/log_test.py b/tornado/test/log_test.py index 9c038ad87..921e86dae 100644 --- a/tornado/test/log_test.py +++ b/tornado/test/log_test.py @@ -27,7 +27,7 @@ from tornado.escape import utf8 from tornado.log import LogFormatter, define_logging_options, enable_pretty_logging from tornado.options import OptionParser from tornado.test.util import unittest -from tornado.util import b, u, bytes_type, basestring_type +from tornado.util import u, bytes_type, basestring_type @contextlib.contextmanager def ignore_bytes_warning(): diff --git a/tornado/test/process_test.py b/tornado/test/process_test.py index bed879085..d7d5dd4dc 100644 --- a/tornado/test/process_test.py +++ b/tornado/test/process_test.py @@ -15,7 +15,6 @@ from tornado.process import fork_processes, task_id, Subprocess from tornado.simple_httpclient import SimpleAsyncHTTPClient from tornado.testing import bind_unused_port, ExpectLog, AsyncTestCase from tornado.test.util import unittest, skipIfNonUnix -from tornado.util import b from tornado.web import RequestHandler, Application diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index 636dd0db7..6db724ead 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -19,7 +19,6 @@ from tornado.test.httpclient_test import ChunkHandler, CountdownHandler, HelloWo from tornado.test import httpclient_test from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, bind_unused_port, ExpectLog from tornado.test.util import unittest -from tornado.util import b from tornado.web import RequestHandler, Application, asynchronous, url diff --git a/tornado/test/stack_context_test.py b/tornado/test/stack_context_test.py index 15833f905..e5a9c0e32 100644 --- a/tornado/test/stack_context_test.py +++ b/tornado/test/stack_context_test.py @@ -5,7 +5,6 @@ from tornado.log import app_log from tornado.stack_context import StackContext, wrap, NullContext from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, ExpectLog from tornado.test.util import unittest -from tornado.util import b from tornado.web import asynchronous, Application, RequestHandler import contextlib import functools diff --git a/tornado/test/template_test.py b/tornado/test/template_test.py index 366fe70fe..a69004c32 100644 --- a/tornado/test/template_test.py +++ b/tornado/test/template_test.py @@ -7,7 +7,7 @@ from tornado.escape import utf8, native_str, to_unicode from tornado.template import Template, DictLoader, ParseError, Loader from tornado.testing import ExpectLog from tornado.test.util import unittest -from tornado.util import b, u, bytes_type, ObjectDict, unicode_type +from tornado.util import u, bytes_type, ObjectDict, unicode_type class TemplateTest(unittest.TestCase): @@ -302,9 +302,9 @@ raw: {% raw name %}""", b"Bobby s") self.assertEqual(loader.load("include.html").generate(name=name), - b("escaped: Bobby <table>s\n" - "unescaped: Bobby
s\n" - "default: Bobby
s\n")) + b"escaped: Bobby <table>s\n" + b"unescaped: Bobby
s\n" + b"default: Bobby
s\n") def test_default_on(self): loader = DictLoader(self.templates, autoescape="xhtml_escape") @@ -317,9 +317,9 @@ raw: {% raw name %}""", b"Bobby <table>s") self.assertEqual(loader.load("include.html").generate(name=name), - b("escaped: Bobby <table>s\n" - "unescaped: Bobby
s\n" - "default: Bobby <table>s\n")) + b"escaped: Bobby <table>s\n" + b"unescaped: Bobby
s\n" + b"default: Bobby <table>s\n") def test_unextended_block(self): loader = DictLoader(self.templates) @@ -350,8 +350,8 @@ raw: {% raw name %}""", def render(name): return loader.load(name).generate(name='<>&"') self.assertEqual(render("raw_expression.html"), - b("expr: <>&"\n" - "raw: <>&\"")) + b"expr: <>&"\n" + b"raw: <>&\"") def test_custom_escape(self): loader = DictLoader({"foo.py": @@ -367,9 +367,9 @@ raw: {% raw name %}""", self.assertEqual(render("foo.py", ""), b"s = ''\n") self.assertEqual(render("foo.py", "';sys.exit()"), - b("""s = "';sys.exit()"\n""")) + b"""s = "';sys.exit()"\n""") self.assertEqual(render("foo.py", ["not a string"]), - b("""s = "['not a string']"\n""")) + b"""s = "['not a string']"\n""") class TemplateLoaderTest(unittest.TestCase): diff --git a/tornado/test/util_test.py b/tornado/test/util_test.py index 002061851..c6b166352 100644 --- a/tornado/test/util_test.py +++ b/tornado/test/util_test.py @@ -3,7 +3,7 @@ from __future__ import absolute_import, division, print_function, with_statement import sys from tornado.escape import utf8 -from tornado.util import raise_exc_info, Configurable, u, b +from tornado.util import raise_exc_info, Configurable, u from tornado.test.util import unittest diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 3e5e370b2..d5a69957c 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -7,7 +7,7 @@ from tornado.simple_httpclient import SimpleAsyncHTTPClient from tornado.template import DictLoader from tornado.testing import AsyncHTTPTestCase, ExpectLog from tornado.test.util import unittest -from tornado.util import b, u, bytes_type, ObjectDict, unicode_type +from tornado.util import u, bytes_type, ObjectDict, unicode_type from tornado.web import RequestHandler, authenticated, Application, asynchronous, url, HTTPError, StaticFileHandler, _create_signature, create_signed_value, ErrorHandler import binascii @@ -70,7 +70,7 @@ class SecureCookieTest(unittest.TestCase): # this string base64-encodes to '12345678' handler.set_secure_cookie('foo', binascii.a2b_hex(b'd76df8e7aefc')) cookie = handler._cookies['foo'] - match = re.match(b(r'12345678\|([0-9]+)\|([0-9a-f]+)'), cookie) + match = re.match(br'12345678\|([0-9]+)\|([0-9a-f]+)', cookie) self.assertTrue(match) timestamp = match.group(1) sig = match.group(2) @@ -559,11 +559,11 @@ class WSGISafeWebTest(WebTestCase): def test_uimodule_unescaped(self): response = self.fetch("/linkify") self.assertEqual(response.body, - b("http://example.com")) + b"http://example.com") def test_uimodule_resources(self): response = self.fetch("/uimodule_resources") - self.assertEqual(response.body, b("""\ + self.assertEqual(response.body, b"""\