From: Ben Darnell Date: Sun, 25 Oct 2015 15:44:06 +0000 (-0400) Subject: Remove the u() function and a few uses the script missed. X-Git-Tag: v4.4.0b1~75^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1477%2Fhead;p=thirdparty%2Ftornado.git Remove the u() function and a few uses the script missed. --- diff --git a/tornado/auth.py b/tornado/auth.py index 0f1b3b13d..05ac3d1ee 100644 --- a/tornado/auth.py +++ b/tornado/auth.py @@ -82,7 +82,7 @@ from tornado import escape from tornado.httputil import url_concat from tornado.log import gen_log from tornado.stack_context import ExceptionStackContext -from tornado.util import u, unicode_type, ArgReplacer +from tornado.util import unicode_type, ArgReplacer try: import urlparse # py2 diff --git a/tornado/escape.py b/tornado/escape.py index b644a4749..23cc9cde4 100644 --- a/tornado/escape.py +++ b/tornado/escape.py @@ -25,7 +25,7 @@ from __future__ import absolute_import, division, print_function, with_statement import re import sys -from tornado.util import unicode_type, basestring_type, u +from tornado.util import unicode_type, basestring_type try: from urllib.parse import parse_qs as _parse_qs # py3 diff --git a/tornado/locale.py b/tornado/locale.py index 07da26df8..0a1b07709 100644 --- a/tornado/locale.py +++ b/tornado/locale.py @@ -51,7 +51,6 @@ import re from tornado import escape from tornado.log import gen_log -from tornado.util import u from tornado._locale_data import LOCALE_NAMES diff --git a/tornado/netutil.py b/tornado/netutil.py index 4fc8d04d9..3c2b61643 100644 --- a/tornado/netutil.py +++ b/tornado/netutil.py @@ -27,7 +27,7 @@ import stat from tornado.concurrent import dummy_executor, run_on_executor from tornado.ioloop import IOLoop from tornado.platform.auto import set_close_exec -from tornado.util import u, Configurable, errno_from_exception +from tornado.util import Configurable, errno_from_exception try: import ssl @@ -96,7 +96,7 @@ else: # module-import time, the import lock is already held by the main thread, # leading to deadlock. Avoid it by caching the idna encoder on the main # thread now. -u('foo').encode('idna') +u'foo'.encode('idna') # These errnos indicate that a non-blocking operation must be retried # at a later time. On most platforms they're the same value, but on diff --git a/tornado/test/auth_test.py b/tornado/test/auth_test.py index a49b27444..0a7d9bbfa 100644 --- a/tornado/test/auth_test.py +++ b/tornado/test/auth_test.py @@ -12,7 +12,6 @@ from tornado import gen from tornado.httputil import url_concat from tornado.log import gen_log from tornado.testing import AsyncHTTPTestCase, ExpectLog -from tornado.util import u from tornado.web import RequestHandler, Application, asynchronous, HTTPError diff --git a/tornado/test/escape_test.py b/tornado/test/escape_test.py index e2c638c28..b3562cd92 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, squeeze, recursive_unicode -from tornado.util import u, unicode_type +from tornado.util import unicode_type from tornado.test.util import unittest linkify_tests = [ @@ -170,8 +170,8 @@ class EscapeTestCase(unittest.TestCase): def test_url_escape_unicode(self): tests = [ # byte strings are passed through as-is - (u('\u00e9').encode('utf8'), '%C3%A9'), - (u('\u00e9').encode('latin1'), '%E9'), + (u'\u00e9'.encode('utf8'), '%C3%A9'), + (u'\u00e9'.encode('latin1'), '%E9'), # unicode strings become utf8 (u'\u00e9', '%C3%A9'), diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index 939bebb89..e1496e9b2 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -23,7 +23,6 @@ from tornado import netutil from tornado.stack_context import ExceptionStackContext, NullContext from tornado.testing import AsyncHTTPTestCase, bind_unused_port, gen_test, ExpectLog from tornado.test.util import unittest, skipOnTravis -from tornado.util import u from tornado.web import Application, RequestHandler, url from tornado.httputil import format_timestamp, HTTPHeaders diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index fd54633be..942bc4cb0 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -14,7 +14,6 @@ from tornado.netutil import ssl_options_to_context from tornado.simple_httpclient import SimpleAsyncHTTPClient from tornado.testing import AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCase, ExpectLog, gen_test from tornado.test.util import unittest, skipOnTravis -from tornado.util import u from tornado.web import Application, RequestHandler, asynchronous, stream_request_body from contextlib import closing import datetime @@ -232,11 +231,11 @@ class HTTPConnectionTest(AsyncHTTPTestCase): b"\r\n".join([ b"Content-Disposition: form-data; name=argument", b"", - u("\u00e1").encode("utf-8"), + u"\u00e1".encode("utf-8"), b"--1234567890", - u('Content-Disposition: form-data; name="files"; filename="\u00f3"').encode("utf8"), + u'Content-Disposition: form-data; name="files"; filename="\u00f3"'.encode("utf8"), b"", - u("\u00fa").encode("utf-8"), + u"\u00fa".encode("utf-8"), b"--1234567890--", b"", ])) diff --git a/tornado/test/httputil_test.py b/tornado/test/httputil_test.py index 7acceae74..75b3dfa22 100644 --- a/tornado/test/httputil_test.py +++ b/tornado/test/httputil_test.py @@ -7,7 +7,6 @@ from tornado.escape import utf8, native_str from tornado.log import gen_log from tornado.testing import ExpectLog from tornado.test.util import unittest -from tornado.util import u import copy import datetime diff --git a/tornado/test/locale_test.py b/tornado/test/locale_test.py index dfa4e4b65..e57a66e68 100644 --- a/tornado/test/locale_test.py +++ b/tornado/test/locale_test.py @@ -8,7 +8,7 @@ import tempfile import tornado.locale from tornado.escape import utf8, to_unicode from tornado.test.util import unittest, skipOnAppEngine -from tornado.util import u, unicode_type +from tornado.util import unicode_type class TranslationLoaderTest(unittest.TestCase): diff --git a/tornado/test/log_test.py b/tornado/test/log_test.py index e45c4e730..da78fc027 100644 --- a/tornado/test/log_test.py +++ b/tornado/test/log_test.py @@ -29,7 +29,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 u, basestring_type +from tornado.util import basestring_type @contextlib.contextmanager @@ -96,7 +96,7 @@ class LogFormatterTest(unittest.TestCase): def test_utf8_logging(self): with ignore_bytes_warning(): - self.logger.error(u("\u00e9").encode("utf8")) + self.logger.error(u"\u00e9".encode("utf8")) if issubclass(bytes, basestring_type): # on python 2, utf8 byte strings (and by extension ascii byte # strings) are passed through as-is. diff --git a/tornado/test/resolve_test_helper.py b/tornado/test/resolve_test_helper.py index 7ee8bfbc6..070222f0d 100644 --- a/tornado/test/resolve_test_helper.py +++ b/tornado/test/resolve_test_helper.py @@ -1,7 +1,6 @@ from __future__ import absolute_import, division, print_function, with_statement from tornado.ioloop import IOLoop from tornado.netutil import ThreadedResolver -from tornado.util import u # When this module is imported, it runs getaddrinfo on a thread. Since # the hostname is unicode, getaddrinfo attempts to import encodings.idna diff --git a/tornado/test/template_test.py b/tornado/test/template_test.py index c48618e03..d49d23279 100644 --- a/tornado/test/template_test.py +++ b/tornado/test/template_test.py @@ -7,7 +7,7 @@ import traceback from tornado.escape import utf8, native_str, to_unicode from tornado.template import Template, DictLoader, ParseError, Loader from tornado.test.util import unittest -from tornado.util import u, ObjectDict, unicode_type +from tornado.util import ObjectDict, unicode_type class TemplateTest(unittest.TestCase): diff --git a/tornado/test/util_test.py b/tornado/test/util_test.py index 353efbbce..98378fa05 100644 --- a/tornado/test/util_test.py +++ b/tornado/test/util_test.py @@ -5,7 +5,7 @@ import datetime import tornado.escape from tornado.escape import utf8 -from tornado.util import raise_exc_info, Configurable, u, exec_in, ArgReplacer, timedelta_to_seconds, import_object +from tornado.util import raise_exc_info, Configurable, exec_in, ArgReplacer, timedelta_to_seconds, import_object from tornado.test.util import unittest try: diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index c9e2c3a87..9f3582d12 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -11,7 +11,7 @@ from tornado.simple_httpclient import SimpleAsyncHTTPClient from tornado.template import DictLoader from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, ExpectLog, gen_test from tornado.test.util import unittest, skipBefore35, exec_test -from tornado.util import u, ObjectDict, unicode_type, timedelta_to_seconds +from tornado.util import ObjectDict, unicode_type, timedelta_to_seconds from tornado.web import RequestHandler, authenticated, Application, asynchronous, url, HTTPError, StaticFileHandler, _create_signature_v1, create_signed_value, decode_signed_value, ErrorHandler, UIModule, MissingArgumentError, stream_request_body, Finish, removeslash, addslash, RedirectHandler as WebRedirectHandler, get_signature_key_version, GZipContentEncoding import binascii diff --git a/tornado/test/websocket_test.py b/tornado/test/websocket_test.py index 86f53e620..f0578ba91 100644 --- a/tornado/test/websocket_test.py +++ b/tornado/test/websocket_test.py @@ -9,7 +9,6 @@ from tornado.log import gen_log, app_log from tornado.testing import AsyncHTTPTestCase, gen_test, bind_unused_port, ExpectLog from tornado.test.util import unittest from tornado.web import Application, RequestHandler -from tornado.util import u try: import tornado.websocket # noqa diff --git a/tornado/test/wsgi_test.py b/tornado/test/wsgi_test.py index 42d74b882..94ee884b7 100644 --- a/tornado/test/wsgi_test.py +++ b/tornado/test/wsgi_test.py @@ -4,7 +4,6 @@ from wsgiref.validate import validator from tornado.escape import json_decode from tornado.test.httpserver_test import TypeCheckHandler from tornado.testing import AsyncHTTPTestCase -from tornado.util import u from tornado.web import RequestHandler, Application from tornado.wsgi import WSGIApplication, WSGIContainer, WSGIAdapter @@ -50,7 +49,7 @@ class WSGIApplicationTest(AsyncHTTPTestCase): def test_path_quoting(self): response = self.fetch("/path/foo%20bar%C3%A9") - self.assertEqual(response.body, u("foo bar\u00e9").encode("utf-8")) + self.assertEqual(response.body, u"foo bar\u00e9".encode("utf-8")) def test_types(self): headers = {"Cookie": "foo=bar"} diff --git a/tornado/util.py b/tornado/util.py index a67ddf50d..5e083961a 100644 --- a/tornado/util.py +++ b/tornado/util.py @@ -84,19 +84,10 @@ class GzipDecompressor(object): return self.decompressobj.flush() -# Fake unicode literal support: Python 3.2 doesn't have the u'' marker for -# literal strings, and alternative solutions like "from __future__ import -# unicode_literals" have other problems (see PEP 414). u() can be applied -# to ascii strings that include \u escapes (but they must not contain -# literal non-ascii characters). if not isinstance(b'', type('')): - def u(s): - return s unicode_type = str basestring_type = str else: - def u(s): - return s.decode('unicode_escape') # These names don't exist in py3, so use noqa comments to disable # warnings in flake8. unicode_type = unicode # noqa