]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
A couple of small 2.6-isms.
authorBen Darnell <ben@bendarnell.com>
Sun, 27 Jan 2013 21:28:35 +0000 (16:28 -0500)
committerBen Darnell <ben@bendarnell.com>
Sun, 27 Jan 2013 21:28:35 +0000 (16:28 -0500)
We can use namedtuple and the new 0o octal literal notation.

tornado/gen.py
tornado/netutil.py
website/sphinx/gen.rst

index 2513a836f11cbcdf7a3decb8f6018b47d4f963bc..434ad4bdf792945aeae90b9f8eb89ebde2fb6bdc 100644 (file)
@@ -64,6 +64,7 @@ is an `Arguments` object, which is a named tuple ``(args, kwargs)``.
 """
 from __future__ import absolute_import, division, print_function, with_statement
 
+import collections
 import functools
 import operator
 import sys
@@ -414,20 +415,4 @@ class Runner(object):
         else:
             return False
 
-# in python 2.6+ this could be a collections.namedtuple
-
-
-class Arguments(tuple):
-    """The result of a yield expression whose callback had more than one
-    argument (or keyword arguments).
-
-    The `Arguments` object can be used as a tuple ``(args, kwargs)``
-    or an object with attributes ``args`` and ``kwargs``.
-    """
-    __slots__ = ()
-
-    def __new__(cls, args, kwargs):
-        return tuple.__new__(cls, (args, kwargs))
-
-    args = property(operator.itemgetter(0))
-    kwargs = property(operator.itemgetter(1))
+Arguments = collections.namedtuple('Arguments', ['args', 'kwargs'])
index 1a80d5de88f1efee6107f12abb6ed5c28683ac0b..fd01c91af0f7d57488005d3eaef18f5fc3921559 100644 (file)
@@ -87,7 +87,7 @@ def bind_sockets(port, address=None, family=socket.AF_UNSPEC, backlog=128, flags
     return sockets
 
 if hasattr(socket, 'AF_UNIX'):
-    def bind_unix_socket(file, mode=int('600', 8), backlog=128):
+    def bind_unix_socket(file, mode=0o600, backlog=128):
         """Creates a listening unix socket.
 
         If a socket with the given name already exists, it will be deleted.
index 4281eb358af9405995c882ed83b693ced8718763..c447c0894d9b27e104c218631cbfd0696b92bcb4 100644 (file)
@@ -12,7 +12,7 @@
    ------------
 
    Instances of the following classes may be used in yield expressions
-   in the generator.  
+   in the generator.
 
    .. autoclass:: Task
 
    Other classes
    -------------
 
-   .. autoclass:: Arguments
+   .. class:: Arguments
+
+      The result of a yield expression whose callback had more than one
+      argument (or keyword arguments).
+
+      The `Arguments` object can be used as a tuple ``(args, kwargs)``
+      or an object with attributes ``args`` and ``kwargs``.