r47198 - initial

hawkowl-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Sun, 10 Apr 2016 00:58:37 -0600 (MDT)
Newsgroups gmane.comp.python.twisted.commits
Message-ID <[email protected]>
Author: hawkowl
Date: Sun Apr 10 00:58:27 2016
New Revision: 47198

Modified:
   branches/oldstyle-internet-8281/twisted/internet/base.py
   branches/oldstyle-internet-8281/twisted/internet/defer.py
   branches/oldstyle-internet-8281/twisted/internet/protocol.py
   branches/oldstyle-internet-8281/twisted/internet/ssl.py
   branches/oldstyle-internet-8281/twisted/internet/udp.py
   branches/oldstyle-internet-8281/twisted/python/_oldstyle.py
   branches/oldstyle-internet-8281/twisted/python/compat.py

Log:
initial

Modified: branches/oldstyle-internet-8281/twisted/internet/base.py
==============================================================================
--- branches/oldstyle-internet-8281/twisted/internet/base.py	(original)
+++ branches/oldstyle-internet-8281/twisted/internet/base.py	Sun Apr 10 00:58:27 2016
@@ -25,6 +25,7 @@
 from twisted.python.compat import unicode, iteritems
 from twisted.python.runtime import seconds as runtimeSeconds, platform
 from twisted.internet.defer import Deferred, DeferredList
+from twisted.python._oldstyle import _oldStyle
 
 # This import is for side-effects!  Even if you don't see any code using it
 # in this module, don't delete it.
@@ -32,6 +33,7 @@
 
 
 @implementer(IDelayedCall)
+@_oldStyle
 class DelayedCall:
 
     # enable .debug to record creator call stack, and it will be logged if
@@ -279,6 +281,7 @@
 
 
 @implementer(IResolverSimple)
+@_oldStyle
 class BlockingResolver:
 
     def getHostByName(self, name, timeout = (1, 3, 11, 45)):
@@ -1015,6 +1018,7 @@
 
 
 @implementer(IConnector)
+@_oldStyle
 class BaseConnector:
     """Basic implementation of connector.
 

Modified: branches/oldstyle-internet-8281/twisted/internet/defer.py
==============================================================================
--- branches/oldstyle-internet-8281/twisted/internet/defer.py	(original)
+++ branches/oldstyle-internet-8281/twisted/internet/defer.py	Sun Apr 10 00:58:27 2016
@@ -30,6 +30,7 @@
 from twisted.logger import Logger
 from twisted.python.deprecate import warnAboutFunction, deprecated
 from twisted.python.versions import Version
+from twisted.python._oldstyle import _oldStyle
 
 log = Logger()
 
@@ -194,6 +195,7 @@
 
 
 
+@_oldStyle
 class Deferred:
     """
     This is a callback which will be put off until later.
@@ -663,6 +665,7 @@
 
 
 
+@_oldStyle
 class DebugInfo:
     """
     Deferred debug helper.
@@ -935,7 +938,7 @@
 
 
 ## deferredGenerator
-
+@_oldStyle
 class waitForDeferred:
     """
     See L{deferredGenerator}.

Modified: branches/oldstyle-internet-8281/twisted/internet/protocol.py
==============================================================================
--- branches/oldstyle-internet-8281/twisted/internet/protocol.py	(original)
+++ branches/oldstyle-internet-8281/twisted/internet/protocol.py	Sun Apr 10 00:58:27 2016
@@ -17,9 +17,11 @@
 from twisted.python import log, failure, components
 from twisted.internet import interfaces, error, defer
 from twisted.logger import _loggerFor
+from twisted.python._oldstyle import _oldStyle
 
 
 @implementer(interfaces.IProtocolFactory, interfaces.ILoggingContext)
+@_oldStyle
 class Factory:
     """
     This is a factory which produces protocols.
@@ -221,6 +223,7 @@
 
 
 
+@_oldStyle
 class ClientCreator:
     """
     Client connections that do not require a factory.
@@ -468,6 +471,7 @@
 
 
 
+@_oldStyle
 class BaseProtocol:
     """
     This is the abstract superclass of all protocols.
@@ -659,6 +663,7 @@
 
 
 
+@_oldStyle
 class AbstractDatagramProtocol:
     """
     Abstract protocol for datagram-oriented transports, e.g. IP, ICMP, ARP, UDP.
@@ -775,6 +780,7 @@
 
 
 @implementer(interfaces.ITransport)
+@_oldStyle
 class FileWrapper:
     """A wrapper around a file-like object to make it behave as a Transport.
 

Modified: branches/oldstyle-internet-8281/twisted/internet/ssl.py
==============================================================================
--- branches/oldstyle-internet-8281/twisted/internet/ssl.py	(original)
+++ branches/oldstyle-internet-8281/twisted/internet/ssl.py	Sun Apr 10 00:58:27 2016
@@ -63,8 +63,10 @@
 
 # Twisted imports
 from twisted.internet import tcp, interfaces
+from twisted.python._oldstyle import _oldStyle
 
 
+@_oldStyle
 class ContextFactory:
     """A factory for SSL context objects, for server SSL connections."""
 
@@ -132,6 +134,7 @@
         return self._context
 
 
+@_oldStyle
 class ClientContextFactory:
     """A context factory for SSL clients."""
 

Modified: branches/oldstyle-internet-8281/twisted/internet/udp.py
==============================================================================
--- branches/oldstyle-internet-8281/twisted/internet/udp.py	(original)
+++ branches/oldstyle-internet-8281/twisted/internet/udp.py	Sun Apr 10 00:58:27 2016
@@ -52,6 +52,7 @@
 # Twisted Imports
 from twisted.internet import base, defer, address
 from twisted.python import log, failure
+from twisted.python._oldstyle import _oldStyle
 from twisted.internet import abstract, error, interfaces
 
 
@@ -421,6 +422,7 @@
 
 
 
+@_oldStyle
 class MulticastMixin:
     """
     Implement multicast functionality.

Modified: branches/oldstyle-internet-8281/twisted/python/_oldstyle.py
==============================================================================
--- branches/oldstyle-internet-8281/twisted/python/_oldstyle.py	(original)
+++ branches/oldstyle-internet-8281/twisted/python/_oldstyle.py	Sun Apr 10 00:58:27 2016
@@ -11,11 +11,11 @@
 import os
 import types
 
-from twisted.python.compat import _PY3
+from twisted.python.compat import _shouldEnableNewStyle, _PY3
 from twisted.python.util import _replaceIf
 
 
-def passthru(arg):
+def passthru(arg, **kwargs):
     """
     Return C{arg}. Do nothing.
 
@@ -26,25 +26,7 @@
 
 
 
-def _shouldEnableNewStyle():
-    """
-    Returns whether or not we should enable the new-style conversion of
-    old-style classes. It inspects the environment for C{TWISTED_NEWSTYLE},
-    accepting an empty string, C{no}, C{false}, C{False}, and C{0} as falsey
-    values and everything else as a truthy value.
-
-    @rtype: L{bool}
-    """
-    value = os.environ.get('TWISTED_NEWSTYLE', '')
-
-    if value in ['', 'no', 'false', 'False', '0']:
-        return False
-    else:
-        return True
-
-
-
-def _ensureOldClass(cls):
+def _ensureOldClass(cls, **kwargs):
     """
     Ensure that C{cls} is an old-style class.
 
@@ -65,10 +47,9 @@
     return cls
 
 
-
 @_replaceIf(_PY3, passthru)
 @_replaceIf(not _shouldEnableNewStyle(), _ensureOldClass)
-def _oldStyle(cls):
+def _oldStyle(cls, bases=(object,)):
     """
     A decorator which conditionally converts old-style classes to new-style
     classes. If it is Python 3, or if the C{TWISTED_NEWSTYLE} environment
@@ -81,4 +62,13 @@
     @return: A new-style version of C{cls}.
     """
     _ensureOldClass(cls)
-    return type(cls.__name__, (object,), cls.__dict__)
+    return type(cls.__name__, bases, cls.__dict__)
+
+
+def _oldStyleWithBases(bases=(object,)):
+    """
+    """
+    def _old(cls):
+        return _oldStyle(cls, bases=bases)
+
+    return _old

Modified: branches/oldstyle-internet-8281/twisted/python/compat.py
==============================================================================
--- branches/oldstyle-internet-8281/twisted/python/compat.py	(original)
+++ branches/oldstyle-internet-8281/twisted/python/compat.py	Sun Apr 10 00:58:27 2016
@@ -40,6 +40,25 @@
     _PY3 = True
 
 
+def _shouldEnableNewStyle():
+    """
+    Returns whether or not we should enable the new-style conversion of
+    old-style classes. It inspects the environment for C{TWISTED_NEWSTYLE},
+    accepting an empty string, C{no}, C{false}, C{False}, and C{0} as falsey
+    values and everything else as a truthy value.
+
+    @rtype: L{bool}
+    """
+    value = os.environ.get('TWISTED_NEWSTYLE', '')
+
+    if value in ['', 'no', 'false', 'False', '0']:
+        return False
+    else:
+        return True
+
+
+_EXPECT_NEWSTYLE = _PY3 or _shouldEnableNewStyle()
+
 
 def currentframe(n=0):
     """