]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Python3 doesn't have a useful basestring type any more :(
authorBen Darnell <ben@bendarnell.com>
Sun, 15 May 2011 23:29:19 +0000 (16:29 -0700)
committerBen Darnell <ben@bendarnell.com>
Sun, 15 May 2011 23:29:19 +0000 (16:29 -0700)
tornado/auth.py
tornado/httpclient.py
tornado/s3server.py
tornado/web.py

index b8ef8727510a40c2c0d8fab04a85b7a858046cea..cb11db0f3ee16a48d1b637f298d39e40ee3aa342 100644 (file)
@@ -59,6 +59,7 @@ import uuid
 from tornado import httpclient
 from tornado import escape
 from tornado.ioloop import IOLoop
+from tornado.util import bytes_type
 
 class OpenIdMixin(object):
     """Abstract implementation of OpenID and Attribute Exchange.
@@ -784,7 +785,7 @@ class FacebookMixin(object):
             args["cancel_url"] = urlparse.urljoin(
                 self.request.full_url(), cancel_uri)
         if extended_permissions:
-            if isinstance(extended_permissions, basestring):
+            if isinstance(extended_permissions, (unicode, bytes_type)):
                 extended_permissions = [extended_permissions]
             args["req_perms"] = ",".join(extended_permissions)
         self.redirect("http://www.facebook.com/login.php?" +
index 2caaf21a3048b036f26c0e9c7a0e8a1e174a2560..5c462e871f17803863fc09407b0fcbd1623b40d9 100644 (file)
@@ -6,7 +6,7 @@ import weakref
 from tornado.escape import utf8
 from tornado import httputil
 from tornado.ioloop import IOLoop
-from tornado.util import import_object
+from tornado.util import import_object, bytes_type
 
 class HTTPClient(object):
     """A blocking HTTP client.
@@ -137,7 +137,7 @@ class AsyncHTTPClient(object):
         on each IOLoop.  Additional arguments may be supported depending
         on the implementation class in use.
         """
-        if isinstance(impl, basestring):
+        if isinstance(impl, (unicode, bytes_type)):
             impl = import_object(impl)
         if impl is not None and not issubclass(impl, AsyncHTTPClient):
             raise ValueError("Invalid AsyncHTTPClient implementation")
index b739c6c3b975479392baa34036d389264f7e0a34..de56776b9133bc929ebc6d7088fdecf67321a36c 100644 (file)
@@ -42,6 +42,7 @@ from tornado import escape
 from tornado import httpserver
 from tornado import ioloop
 from tornado import web
+from tornado.util import bytes_type
 
 def start(port, root_directory="/tmp/s3", bucket_depth=0):
     """Starts the mock S3 server on the given port at the given path."""
@@ -86,7 +87,7 @@ class BaseRequestHandler(web.RequestHandler):
                     ''.join(parts))
 
     def _render_parts(self, value, parts=[]):
-        if isinstance(value, basestring):
+        if isinstance(value, (unicode, bytes_type)):
             parts.append(escape.xhtml_escape(value))
         elif isinstance(value, int) or isinstance(value, long):
             parts.append(str(value))
index 07021315d79a3e392115347da18cc5b6dca11c6c..61a674dcf7ace24317ddac9454fcd179aae2ce1e 100644 (file)
@@ -206,7 +206,7 @@ class RequestHandler(object):
         HTTP specification. If the value is not a string, we convert it to
         a string. All header values are then encoded as UTF-8.
         """
-        if isinstance(value, basestring):
+        if isinstance(value, (unicode, bytes_type)):
             value = utf8(value)
             # If \n is allowed into the header, it is possible to inject
             # additional headers or split the request. Also cap length to
@@ -439,7 +439,7 @@ class RequestHandler(object):
             if embed_part: js_embed.append(utf8(embed_part))
             file_part = module.javascript_files()
             if file_part:
-                if isinstance(file_part, basestring):
+                if isinstance(file_part, (unicode, bytes_type)):
                     js_files.append(file_part)
                 else:
                     js_files.extend(file_part)
@@ -447,7 +447,7 @@ class RequestHandler(object):
             if embed_part: css_embed.append(utf8(embed_part))
             file_part = module.css_files()
             if file_part:
-                if isinstance(file_part, basestring):
+                if isinstance(file_part, (unicode, bytes_type)):
                     css_files.append(file_part)
                 else:
                     css_files.extend(file_part)