From: Brett Cannon Date: Fri, 27 Mar 2015 16:56:57 +0000 (-0400) Subject: Fix module deprecation warnings to have a useful stacklevel X-Git-Tag: v3.5.0a3~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=781692ff6af7747948b956eca9b435c9c93c3407;p=python Fix module deprecation warnings to have a useful stacklevel --- diff --git a/Lib/formatter.py b/Lib/formatter.py index cc2f4ad18b..5e8e2ff377 100644 --- a/Lib/formatter.py +++ b/Lib/formatter.py @@ -21,7 +21,7 @@ manage and inserting data into the output. import sys import warnings warnings.warn('the formatter module is deprecated and will be removed in ' - 'Python 3.6', DeprecationWarning) + 'Python 3.6', DeprecationWarning, stacklevel=2) AS_IS = None diff --git a/Lib/imp.py b/Lib/imp.py index 59ce41cc0a..3e6752a11b 100644 --- a/Lib/imp.py +++ b/Lib/imp.py @@ -29,7 +29,7 @@ import warnings warnings.warn("the imp module is deprecated in favour of importlib; " "see the module's documentation for alternative uses", - PendingDeprecationWarning) + PendingDeprecationWarning, stacklevel=2) # DEPRECATED SEARCH_ERROR = 0