Ticket #5451: patch_5451.2.patch

File patch_5451.2.patch, 5.1 KB (added by moijes12, 2 years ago)

Please use this patch and not the previous one for review.

  • 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), "", "twisted.python.reflect", "Settable") 
     49 
    4750    def __init__(self, **kw): 
    4851        self(**kw) 
    4952 
     
    7578 
    7679    """ 
    7780 
     81    deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "AccessorType") 
     82 
    7883    def __init__(self, name, bases, d): 
    7984        type.__init__(self, name, bases, d) 
    8085        accessors = {} 
     
    138143    # caused by it. 
    139144    #  -- itamar 
    140145 
     146    deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "PropertyAccessor") 
    141147    __metaclass__ = AccessorType 
    142148 
    143149    def reallySet(self, k, v): 
     
    159165    This implementation is for Python 2.1. 
    160166    """ 
    161167 
     168    deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "Accessor") 
     169 
    162170    def __setattr__(self, k,v): 
    163171        kstring='set_%s'%k 
    164172        if hasattr(self.__class__,kstring): 
     
    199207 
    200208# just in case 
    201209OriginalAccessor = Accessor 
    202  
     210deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "OriginalAccessor") 
    203211 
    204212class Summer(Accessor): 
    205213    """ 
     
    214222    incremented, similiarly for the debit versions. 
    215223    """ 
    216224 
     225    deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "Summer") 
     226 
    217227    def reallySet(self, k,v): 
    218228        "This method does the work." 
    219229        for sum in self.sums: 
  • 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 
  • 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 test_settable(self): 
     786        """ 
     787        Test deprecation of L{reflect.Settable} 
     788        """ 
     789        settable = reflect.Settable() 
     790        warnings = self.flushWarnings([self.test_settable]) 
     791        self.assertSubstring("twisted.python.reflect.Settable was deprecated in Twisted 12.1.0", warnings[0]['message']) 
     792        self.assertEqual(len(warnings),1) 
     793 
     794    def test_accessorType(self): 
     795        """ 
     796        Test deprecation of L{reflect.AccessorType} 
     797        """ 
     798        accessorType = reflect.AccessorType('', (), {}) 
     799        warnings = self.flushWarnings([self.test_accessorType]) 
     800        self.assertSubstring("twisted.python.reflect.AccessorType was deprecated in Twisted 12.1.0", warnings[0]['message']) 
     801        self.assertEqual(len(warnings),1) 
     802 
     803    def test_propertyAccessor(self): 
     804        """ 
     805        Test deprecation of L{reflect.PropertyAccessor} 
     806        """ 
     807        accessorType = reflect.PropertyAccessor() 
     808        warnings = self.flushWarnings([self.test_propertyAccessor]) 
     809        self.assertSubstring("twisted.python.reflect.PropertyAccessor was deprecated in Twisted 12.1.0", warnings[0]['message']) 
     810        self.assertEqual(len(warnings),1) 
     811 
     812    def test_accessor(self): 
     813        """ 
     814        Test deprecation of L{reflect.Accessor} 
     815        """ 
     816        accessorType = reflect.Accessor() 
     817        warnings = self.flushWarnings([self.test_accessor]) 
     818        self.assertSubstring("twisted.python.reflect.Accessor was deprecated in Twisted 12.1.0", warnings[0]['message']) 
     819        self.assertEqual(len(warnings),1) 
     820 
     821    def test_originalAccessor(self): 
     822        """ 
     823        Test deprecation of L{reflect.OriginalAccessor} 
     824        """ 
     825        from twisted.python.reflect import OriginalAccessor 
     826        warnings = self.flushWarnings([self.test_originalAccessor]) 
     827        self.assertSubstring("twisted.python.reflect.OriginalAccessor was deprecated in Twisted 12.1.0", warnings[0]['message']) 
     828        self.assertEqual(len(warnings),1) 
     829 
     830    def test_summer(self): 
     831        """ 
     832        Test deprecation of L{reflect.Summer} 
     833        """ 
     834        accessorType = reflect.Summer() 
     835        warnings = self.flushWarnings([self.test_summer]) 
     836        self.assertSubstring("twisted.python.reflect.Summer was deprecated in Twisted 12.1.0", warnings[0]['message']) 
     837        self.assertEqual(len(warnings),1) 
     838 No newline at end of file