[patch] deprecation warnings branch
Robert Collins
robertc at robertcollins.net
Thu Jan 5 11:53:29 GMT 2006
Hi. seeking a +1:
http://people.ubuntu.com/~robertc/baz2.0/deprecation
Patch attached, without NEWS or HACKING entry, which I am adding now.
This adds deprecated_method and deprecated_function decorators. Heres
how they work:
@deprecated_function(zero_seven)
def get_bzr_revision():
"""If bzr is run from a branch, return (revno,revid) or None."""
import bzrlib.errors
...
results in the following pydoc output:
Help on function decorated_function in bzrlib:
bzrlib.get_bzr_revision = decorated_function(*args, **kwargs)
If bzr is run from a branch, return (revno,revid) or None.
This function was deprecated in version 0.7.
I'm not sure how to change the 'bzrlib.get_bzr_revision =
decorated_function(*args, **kwargs)' line - that seems a little ugly to
me right now.
Running it:
>>> import bzrlib
>>> bzrlib.get_bzr_revision()
bzrlib/symbol_versioning.py:56: DeprecationWarning:
bzrlib.get_bzr_revision was deprecated in version 0.7.
warn(deprecation_version % symbol, DeprecationWarning)
(1441, u'robertc at robertcollins.net-20060105114350-e21c40532770563e')
>>> bzrlib.get_bzr_revision()
(1441, u'robertc at robertcollins.net-20060105114350-e21c40532770563e')
Thats using the warning module, which can be filtered by front ends like
hct or pqm. Note how its only issued once in the process lifetime.
Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deprecation.patch
Type: text/x-patch
Size: 9515 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060105/41c6fcc5/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060105/41c6fcc5/attachment.pgp
More information about the bazaar
mailing list