D3331: util: set correct stack level on deprecation warnings

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Apr 13 21:30:06 UTC 2018


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Without this patch, you'll get something like this:
  
    <path>/mercurial/util.py:3784: DeprecationWarning: 'util.hgexecutable'
        is deprecated, use 'utils.procutil.hgexecutable'
  
  (but on one line)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3331

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -3781,7 +3781,7 @@
         fn = pycompat.sysbytes(func.__name__)
         mn = modname or pycompat.sysbytes(func.__module__)[len('mercurial.'):]
         msg = "'util.%s' is deprecated, use '%s.%s'" % (fn, mn, fn)
-        nouideprecwarn(msg, version)
+        nouideprecwarn(msg, version, stacklevel=2)
         return func(*args, **kwargs)
     wrapped.__name__ = func.__name__
     return wrapped



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list