]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Remove the u() function and a few uses the script missed. 1477/head
authorBen Darnell <ben@bendarnell.com>
Sun, 25 Oct 2015 15:44:06 +0000 (11:44 -0400)
committerBen Darnell <ben@bendarnell.com>
Fri, 6 Nov 2015 23:53:11 +0000 (18:53 -0500)
18 files changed:
tornado/auth.py
tornado/escape.py
tornado/locale.py
tornado/netutil.py
tornado/test/auth_test.py
tornado/test/escape_test.py
tornado/test/httpclient_test.py
tornado/test/httpserver_test.py
tornado/test/httputil_test.py
tornado/test/locale_test.py
tornado/test/log_test.py
tornado/test/resolve_test_helper.py
tornado/test/template_test.py
tornado/test/util_test.py
tornado/test/web_test.py
tornado/test/websocket_test.py
tornado/test/wsgi_test.py
tornado/util.py

index 0f1b3b13d6f9ad679f0ee2ace84fbaef11016b59..05ac3d1ee7de5330e85e435cf2da783636345285 100644 (file)
@@ -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
index b644a474913df648c8f64db60418607c07e15b30..23cc9cde46e1ca9ee8deaccd7860c45f7f7994d5 100644 (file)
@@ -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
index 07da26df85b108a7e918451b30aeb8c591494341..0a1b077095415be3e037b70a062af84f6a678e3e 100644 (file)
@@ -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
 
index 4fc8d04d9c75aba25ab55920bee242dbc1a8a968..3c2b61643529d53105698eb67f59fb1fbfd7fb8a 100644 (file)
@@ -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
index a49b2744451da58f2a91bb8892b84ca40d24a268..0a7d9bbfa4ade706014bc753ed3693c137fbb9c0 100644 (file)
@@ -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
 
 
index e2c638c287390b8177ef7de04fbb8d30e151fc45..b3562cd92872ed8281b956e0ac169083ddabf18a 100644 (file)
@@ -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'),
index 939bebb89391572f2ee137575d8f546e85cdf139..e1496e9b2ed5d36de1bb683afded7eda6bef373c 100644 (file)
@@ -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
 
index fd54633be041c178006bee37dff7ed4a86f7722a..942bc4cb0d905940e57465055b20fcdc13a6966c 100644 (file)
@@ -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"",
             ]))
index 7acceae749e5d61222c914ab4152b47075c7c8c3..75b3dfa224c262bcdca218c4ddaa489248cfbdc1 100644 (file)
@@ -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
index dfa4e4b653c6e22d29f6f7b91f56c16ecb3bfcf8..e57a66e686f217de94788b3009d46370a3873f77 100644 (file)
@@ -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):
index e45c4e730c475a646ae1f85363045d17f1c61427..da78fc027d2fdc3ba1d56a5135d1eeab09f861fe 100644 (file)
@@ -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.
index 7ee8bfbc6df2c180138d03899ebb8327df038f6a..070222f0dfc58cc5271e86f946f26541dcefa1ac 100644 (file)
@@ -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
index c48618e03f6007b676f02006d78f0a189496d2d0..d49d2327913071ba41a21a94565ff1c80457ec9a 100644 (file)
@@ -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):
index 353efbbce154cd7cd417ced0ade86d5622f90182..98378fa0514a85ebeda5cc66f92625d158453df1 100644 (file)
@@ -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:
index c9e2c3a8724699fbaf4822f1e2aa51427fda3f19..9f3582d12905ff5a78749b2834c0e34112201963 100644 (file)
@@ -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
index 86f53e620975946e85b4168abef5b1a9ac099c59..f0578ba913635246090ccac652dff743b5411c79 100644 (file)
@@ -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
index 42d74b88281509893bfd10a70d63e50008c7ce18..94ee884b7e347741c4e27a6cbc5774bde0c08fa7 100644 (file)
@@ -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"}
index a67ddf50db5a0d90187bcc4a2962d40868a2dc53..5e083961a10bf9b00d87559502176c6b61cadaaa 100644 (file)
@@ -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