Merge lp:~mnordhoff/bzr/bencode-deprecation-stacklevel into lp:~bzr/bzr/trunk-old

Proposed by Matt Nordhoff
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mnordhoff/bzr/bencode-deprecation-stacklevel
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 11 lines
To merge this branch: bzr merge lp:~mnordhoff/bzr/bencode-deprecation-stacklevel
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+7824@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Matt Nordhoff (mnordhoff) wrote :

Look, another trivial patch.

bzrlib.util.bencode's deprecation warning didn't pass stacklevel=2, so it just said:

.../bzrlib/util/bencode.py:22: DeprecationWarning: bzrlib.util.bencode was deprecated in version 1.16.

...which is rather unhelpful.

Revision history for this message
Martin Pool (mbp) :
review: Approve
Revision history for this message
Matt Nordhoff (mnordhoff) wrote :

John A Meinel wrote:
> What does it give you with stacklevel=2 ? I was considering that, but I
> didn't know what stack would give you for "import".
>
> Anyway, if it gives something more useful:
> vote approve

Seems to do the right thing:

>>> import bzrlib.util.bencode
__main__:1: DeprecationWarning: bzrlib.util.bencode was deprecated in
version 1.16.
  Use bzrlib.bencode instead

Less so when you use lazy_import, but it's not really any worse:

>>> lazy_import(globals(), "import bzrlib.util.bencode")
>>> bzrlib.util.bencode.__doc__
bzrlib/lazy_import.py:195: DeprecationWarning: bzrlib.util.bencode was
deprecated in version 1.16.
  Use bzrlib.bencode instead
  module = __import__(module_python_path, scope, scope, [])
--

Updating diff...

An updated diff will be available in a few minutes. Reload to see the changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/util/bencode.py'
2--- bzrlib/util/bencode.py 2009-06-09 14:18:41 +0000
3+++ bzrlib/util/bencode.py 2009-06-24 02:35:16 +0000
4@@ -19,6 +19,6 @@
5 dep_warning = symbol_versioning.deprecated_in((1, 16, 0)) % (
6 'bzrlib.util.bencode',) + '\n Use bzrlib.bencode instead'
7
8-symbol_versioning.warn(dep_warning, DeprecationWarning)
9+symbol_versioning.warn(dep_warning, DeprecationWarning, stacklevel=2)
10
11 from bzrlib.bencode import *