~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/symbol_versioning.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-03 18:09:01 UTC
  • mfrom: (3159.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20080103180901-w987y1ftqoh02qbm
(vila) Fix #179368 by keeping the current range hint on
        ShortReadvErrors

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
           'zero_sixteen',
38
38
           'zero_seventeen',
39
39
           'zero_eighteen',
 
40
           'zero_ninety',
 
41
           'zero_ninetyone',
 
42
           'zero_ninetytwo',
 
43
           'zero_ninetythree',
 
44
           'one_zero',
 
45
           'one_one',
40
46
           ]
41
47
 
42
48
from warnings import warn
55
61
zero_sixteen = "%s was deprecated in version 0.16."
56
62
zero_seventeen = "%s was deprecated in version 0.17."
57
63
zero_eighteen = "%s was deprecated in version 0.18."
 
64
zero_ninety = "%s was deprecated in version 0.90."
 
65
zero_ninetyone = "%s was deprecated in version 0.91."
 
66
zero_ninetytwo = "%s was deprecated in version 0.92."
 
67
one_zero = "%s was deprecated in version 1.0."
 
68
zero_ninetythree = one_zero # Maintained for backwards compatibility
 
69
one_one = "%s was deprecated in version 1.1."
58
70
 
59
71
 
60
72
def set_warning_method(method):
80
92
        have a single %s operator in it. a_callable will be turned into a nice
81
93
        python symbol and then substituted into deprecation_version.
82
94
    """
 
95
    # We also want to handle old-style classes, in particular exception, and
 
96
    # they don't have an im_class attribute.
83
97
    if getattr(a_callable, 'im_class', None) is None:
84
98
        symbol = "%s.%s" % (a_callable.__module__,
85
99
                            a_callable.__name__)
110
124
 
111
125
def deprecated_method(deprecation_version):
112
126
    """Decorate a method so that use of it will trigger a warning.
 
127
 
 
128
    To deprecate a static or class method, use 
 
129
 
 
130
        @staticmethod
 
131
        @deprecated_function
 
132
        def ...
113
133
    
114
134
    To deprecate an entire class, decorate __init__.
115
135
    """
119
139
        
120
140
        def decorated_method(self, *args, **kwargs):
121
141
            """This is the decorated method."""
122
 
            symbol = "%s.%s.%s" % (self.__class__.__module__,
123
 
                                   self.__class__.__name__,
124
 
                                   callable.__name__
125
 
                                   )
 
142
            if callable.__name__ == '__init__':
 
143
                symbol = "%s.%s" % (self.__class__.__module__,
 
144
                                    self.__class__.__name__,
 
145
                                    )
 
146
            else:
 
147
                symbol = "%s.%s.%s" % (self.__class__.__module__,
 
148
                                       self.__class__.__name__,
 
149
                                       callable.__name__
 
150
                                       )
126
151
            warn(deprecation_version % symbol, DeprecationWarning, stacklevel=2)
127
152
            return callable(self, *args, **kwargs)
128
153
        _populate_decorated(callable, deprecation_version, "method",