Ticket #5451: Twisted_5451.patch

File Twisted_5451.patch, 6.5 KB (added by moijes12, 2 years ago)

Required changes are mage

  • twisted/python/reflect.py

     
    3030    from StringIO import StringIO 
    3131 
    3232from twisted.python.util import unsignedID 
    33 from twisted.python.deprecate import deprecated 
     33from twisted.python.deprecate import deprecated, deprecatedModuleAttribute 
    3434from twisted.python.deprecate import _fullyQualifiedName as fullyQualifiedName 
    3535from twisted.python.versions import Version 
    3636 
     
    4444    where you don't want to name a variable, but you do want to set 
    4545    some attributes; for example, C{X()(y=z,a=b)}. 
    4646    """ 
     47 
     48    deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), 
     49    "Settable is an implementation for Python 2.2 and earlier which are no " 
     50    "longer supported by Twisted.", "twisted.python.reflect", "Settable") 
     51 
    4752    def __init__(self, **kw): 
    4853        self(**kw) 
    4954 
     
    7580 
    7681    """ 
    7782 
     83    deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), 
     84    "AccessorType is an implementation for Python 2.2 which is no longer " 
     85    "supported by Twisted.", "twisted.python.reflect", "AccessorType") 
     86     
    7887    def __init__(self, name, bases, d): 
    7988        type.__init__(self, name, bases, d) 
    8089        accessors = {} 
     
    138147    # caused by it. 
    139148    #  -- itamar 
    140149 
     150    deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), 
     151    "PropertyAccessor is an implementation for Python 2.2 and earlier which " 
     152    "are no longer supported by Twisted.","twisted.python.reflect", 
     153    "PropertyAccessor") 
    141154    __metaclass__ = AccessorType 
    142155 
    143156    def reallySet(self, k, v): 
     
    159172    This implementation is for Python 2.1. 
    160173    """ 
    161174 
     175    deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), 
     176    "Accessor is an implementation for Python 2.1 which is no longer " 
     177    "supported by Twisted.", "twisted.python.reflect", "Accessor") 
     178 
    162179    def __setattr__(self, k,v): 
    163180        kstring='set_%s'%k 
    164181        if hasattr(self.__class__,kstring): 
     
    199216 
    200217# just in case 
    201218OriginalAccessor = Accessor 
     219deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), 
     220"OriginalAccessor is a reference to class twisted.python.reflect.Accessor " 
     221"which is deprecated.", "twisted.python.reflect", "OriginalAccessor") 
    202222 
    203223 
    204224class Summer(Accessor): 
     
    214234    incremented, similiarly for the debit versions. 
    215235    """ 
    216236 
     237    deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), 
     238    "Summer is a child class of twisted.python.reflect.Accessor which is "  
     239    "deprecated.", "twisted.python.reflect", "Summer") 
     240 
    217241    def reallySet(self, k,v): 
    218242        "This method does the work." 
    219243        for sum in self.sums: 
  • twisted/test/test_reflect.py

     
    781781        self.callDeprecated( 
    782782            (Version("Twisted", 11, 0, 0), "inspect.getmro"), 
    783783            reflect.accumulateBases, DeprecationTestCase, l, None) 
     784 
     785    def lookForDeprecationWarning(self, testMethod, attributeName, warningMsg): 
     786        """ 
     787        Test deprecation of attribute 'reflect.attributeName' by calling 
     788        'reflect.testMethod' and verifying the warning message  
     789        'reflect.warningMsg' 
     790         
     791        @param testMethod : Name of the offending function to be used with 
     792                            flushWarnings 
     793        @type testmethod : C{str} 
     794         
     795        @param attributeName : Name of attribute to be checked for deprecation 
     796        @type attributeName : C{str} 
     797         
     798        @param warningMsg : Deprecation warning message 
     799        @type warningMsg : C{str} 
     800       """ 
     801        warningsShown = self.flushWarnings([testMethod])  
     802        self.assertEqual(len(warningsShown), 1) 
     803        self.assertIdentical(warningsShown[0]['category'], DeprecationWarning) 
     804        self.assertEqual( 
     805            warningsShown[0]['message'], 
     806            "twisted.python.reflect." + attributeName + " " 
     807            "was deprecated in Twisted 12.1.0: " + warningMsg + ".") 
     808 
     809    def test_settable(self): 
     810        """ 
     811        Test deprecation of L{reflect.Settable} 
     812        """ 
     813        reflect.Settable() 
     814        self.lookForDeprecationWarning(self.test_settable, "Settable", 
     815            "Settable is an implementation for Python 2.2 and earlier which " 
     816            "are no longer supported by Twisted") 
     817 
     818    def test_accessorType(self): 
     819        """ 
     820        Test deprecation of L{reflect.AccessorType} 
     821        """ 
     822        reflect.AccessorType(' ', ( ), { }) 
     823        self.lookForDeprecationWarning(self.test_accessorType, "AccessorType", 
     824            "AccessorType is an implementation for " 
     825            "Python 2.2 which is no longer supported by Twisted") 
     826 
     827    def test_propertyAccessor(self): 
     828        """ 
     829        Test deprecation of L{reflect.PropertyAccessor} 
     830        """ 
     831        reflect.PropertyAccessor() 
     832        self.lookForDeprecationWarning(self.test_propertyAccessor, 
     833            "PropertyAccessor", 
     834            "PropertyAccessor is an implementation for Python 2.2 and earlier" 
     835            " which are no longer supported by Twisted") 
     836 
     837    def test_accessor(self): 
     838        """  
     839        Test deprecation of L{reflect.Accessor} 
     840        """ 
     841        reflect.Accessor() 
     842        self.lookForDeprecationWarning(self.test_accessor, "Accessor", 
     843            "Accessor is an implementation for Python 2.1 which is no longer " 
     844            "supported by Twisted") 
     845 
     846    def test_originalAccessor(self): 
     847        """ 
     848        Test deprecation of L{reflect.OriginalAccessor} 
     849        """ 
     850        reflect.OriginalAccessor() 
     851        self.lookForDeprecationWarning(self.test_originalAccessor,  
     852            "OriginalAccessor", "OriginalAccessor is a reference to class " 
     853            "twisted.python.reflect.Accessor which is deprecated") 
     854 
     855    def test_summer(self): 
     856        """ 
     857        Test deprecation of L{reflect.Summer} 
     858        """ 
     859        reflect.Summer() 
     860        self.lookForDeprecationWarning(self.test_summer, "Summer", 
     861            "Summer is a child class of twisted.python.reflect.Accessor which" 
     862            " is deprecated") 
     863 No newline at end of file 
  • twisted/topfiles/5451.removal

     
     1twisted.python.reflect's Settable, AccessorType, PropertyAccessor, Accessor, OriginalAccessor and Summer are now deprecated.  
     2 No newline at end of file