r47241 - remove
hawkowl-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Thu, 14 Apr 2016 20:14:17 -0600 (MDT)
| Newsgroups | gmane.comp.python.twisted.commits |
|---|---|
| Message-ID | <[email protected]> |
Author: hawkowl
Date: Thu Apr 14 20:14:11 2016
New Revision: 47241
Added:
branches/removeoldreflect-8293/twisted/topfiles/8293.removal
Modified:
branches/removeoldreflect-8293/twisted/python/reflect.py
branches/removeoldreflect-8293/twisted/test/test_reflect.py
Log:
remove
Modified: branches/removeoldreflect-8293/twisted/python/reflect.py
==============================================================================
--- branches/removeoldreflect-8293/twisted/python/reflect.py (original)
+++ branches/removeoldreflect-8293/twisted/python/reflect.py Thu Apr 14 20:14:11 2016
@@ -16,7 +16,6 @@
import weakref
import re
import traceback
-import warnings
from collections import deque
RegexType = type(re.compile(""))
@@ -24,10 +23,8 @@
from twisted.python.compat import reraise, nativeString, NativeStringIO
from twisted.python.compat import _PY3
-from twisted.python.deprecate import deprecated
from twisted.python import compat
from twisted.python.deprecate import _fullyQualifiedName as fullyQualifiedName
-from twisted.python.versions import Version
def prefixedMethodNames(classObj, prefix):
@@ -456,38 +453,6 @@
self.calls.append((self.name, args))
-def funcinfo(function):
- """
- this is more documentation for myself than useful code.
- """
- warnings.warn(
- "[v2.5] Use inspect.getargspec instead of twisted.python.reflect.funcinfo",
- DeprecationWarning,
- stacklevel=2)
- code=function.func_code
- name=function.func_name
- argc=code.co_argcount
- argv=code.co_varnames[:argc]
- defaults=function.func_defaults
-
- out = []
-
- out.append('The function %s accepts %s arguments' % (name ,argc))
- if defaults:
- required=argc-len(defaults)
- out.append('It requires %s arguments' % required)
- out.append('The arguments required are: %s' % argv[:required])
- out.append('additional arguments are:')
- for i in range(argc-required):
- j=i+required
- out.append('%s which has a default of' % (argv[j], defaults[i]))
- return out
-
-
-ISNT=0
-WAS=1
-IS=2
-
def fullFuncName(func):
qualName = (str(pickle.whichmodule(func, func.__name__)) + '.' + func.__name__)
@@ -496,6 +461,7 @@
return qualName
+
def getClass(obj):
"""
Return the class or type of object 'obj'.
@@ -507,72 +473,6 @@
return type(obj)
-## the following were factored out of usage
-
-if not _PY3:
- # The following functions aren't documented, nor tested, have much simpler
- # builtin implementations and are not used within Twisted or "known"
- # projects.
-
- @deprecated(Version("Twisted", 14, 0, 0))
- def getcurrent(clazz):
- assert type(clazz) == types.ClassType, 'must be a class...'
- module = namedModule(clazz.__module__)
- currclass = getattr(module, clazz.__name__, None)
- if currclass is None:
- return clazz
- return currclass
-
-
- # Class graph nonsense
- # I should really have a better name for this...
- @deprecated(Version("Twisted", 14, 0, 0), "isinstance")
- def isinst(inst,clazz):
- if type(inst) != compat.InstanceType or type(clazz)!= types.ClassType:
- return isinstance(inst,clazz)
- cl = inst.__class__
- cl2 = getcurrent(cl)
- clazz = getcurrent(clazz)
- if issubclass(cl2,clazz):
- if cl == cl2:
- return WAS
- else:
- inst.__class__ = cl2
- return IS
- else:
- return ISNT
-
-
- # These functions are still imported by libraries used in turn by the
- # Twisted unit tests, like Nevow 0.10. Since they are deprecated,
- # there's no need to port them to Python 3 (hence the condition above).
- # https://bazaar.launchpad.net/~divmod-dev/divmod.org/trunk/revision/2716
- # removed the dependency in Nevow. Once that is released, these functions
- # can be safely removed from Twisted.
-
- @deprecated(Version("Twisted", 11, 0, 0), "inspect.getmro")
- def allYourBase(classObj, baseClass=None):
- """
- allYourBase(classObj, baseClass=None) -> list of all base
- classes that are subclasses of baseClass, unless it is None,
- in which case all bases will be added.
- """
- l = []
- _accumulateBases(classObj, l, baseClass)
- return l
-
-
- @deprecated(Version("Twisted", 11, 0, 0), "inspect.getmro")
- def accumulateBases(classObj, l, baseClass=None):
- _accumulateBases(classObj, l, baseClass)
-
-
- def _accumulateBases(classObj, l, baseClass=None):
- for base in classObj.__bases__:
- if baseClass is None or issubclass(base, baseClass):
- l.append(base)
- _accumulateBases(base, l, baseClass)
-
def accumulateClassDict(classObj, attr, adict, baseClass=None):
"""
@@ -709,15 +609,11 @@
__all__ = [
'InvalidName', 'ModuleNotFound', 'ObjectNotFound',
- 'ISNT', 'WAS', 'IS',
-
'QueueMethod',
- 'funcinfo', 'fullFuncName', 'qual', 'getcurrent', 'getClass', 'isinst',
'namedModule', 'namedObject', 'namedClass', 'namedAny', 'requireModule',
- 'safe_repr', 'safe_str', 'allYourBase', 'accumulateBases',
- 'prefixedMethodNames', 'addMethodNamesToDict', 'prefixedMethods',
- 'accumulateMethods',
+ 'safe_repr', 'safe_str', 'prefixedMethodNames', 'addMethodNamesToDict',
+ 'prefixedMethods', 'accumulateMethods', 'fullFuncName', 'qual', 'getClass',
'accumulateClassDict', 'accumulateClassList', 'isSame', 'isLike',
'modgrep', 'isOfType', 'findInstances', 'objgrep', 'filenameToModuleName',
'fullyQualifiedName']
Modified: branches/removeoldreflect-8293/twisted/test/test_reflect.py
==============================================================================
--- branches/removeoldreflect-8293/twisted/test/test_reflect.py (original)
+++ branches/removeoldreflect-8293/twisted/test/test_reflect.py Thu Apr 14 20:14:11 2016
@@ -18,7 +18,6 @@
from twisted.python.reflect import (
accumulateMethods, prefixedMethods, prefixedMethodNames,
addMethodNamesToDict, fullyQualifiedName)
-from twisted.python.versions import Version
class Base(object):
@@ -891,56 +890,3 @@
new = NewClass()
self.assertEqual(reflect.getClass(NewClass).__name__, 'type')
self.assertEqual(reflect.getClass(new).__name__, 'NewClass')
-
-
-if not _PY3:
- # The functions tested below are deprecated but still used by external
- # projects like Nevow 0.10. They are not going to be ported to Python 3
- # (hence the condition above) and will be removed as soon as no project used
- # by Twisted will depend on these functions. Also, have a look at the
- # comments related to those functions in twisted.python.reflect.
- class DeprecationTests(unittest.TestCase):
- """
- Test deprecations in twisted.python.reflect
- """
-
- def test_allYourBase(self):
- """
- Test deprecation of L{reflect.allYourBase}. See #5481 for removal.
- """
- self.callDeprecated(
- (Version("Twisted", 11, 0, 0), "inspect.getmro"),
- reflect.allYourBase, DeprecationTests)
-
-
- def test_accumulateBases(self):
- """
- Test deprecation of L{reflect.accumulateBases}. See #5481 for removal.
- """
- l = []
- self.callDeprecated(
- (Version("Twisted", 11, 0, 0), "inspect.getmro"),
- reflect.accumulateBases, DeprecationTests, l, None)
-
-
- def test_getcurrent(self):
- """
- Test deprecation of L{reflect.getcurrent}.
- """
-
- class C:
- pass
-
- self.callDeprecated(
- Version("Twisted", 14, 0, 0),
- reflect.getcurrent, C)
-
-
- def test_isinst(self):
- """
- Test deprecation of L{reflect.isinst}.
- """
-
- self.callDeprecated(
- (Version("Twisted", 14, 0, 0), "isinstance"),
- reflect.isinst, object(), object)