[Python-checkins] cpython: Set stacklevel to 2 to get more accurate warning messages from deprecated
berker.peksag
python-checkins at python.org
Thu May 21 22:40:52 CEST 2015
https://hg.python.org/cpython/rev/6362e9dc09de
changeset: 96197:6362e9dc09de
user: Berker Peksag <berker.peksag at gmail.com>
date: Thu May 21 23:40:54 2015 +0300
summary:
Set stacklevel to 2 to get more accurate warning messages from deprecated functions.
files:
Lib/inspect.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Lib/inspect.py b/Lib/inspect.py
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -2662,7 +2662,8 @@
"""Constructs Signature for the given python function."""
warnings.warn("inspect.Signature.from_function() is deprecated, "
- "use Signature.from_callable()", DeprecationWarning)
+ "use Signature.from_callable()",
+ DeprecationWarning, stacklevel=2)
return _signature_from_function(cls, func)
@classmethod
@@ -2670,7 +2671,8 @@
"""Constructs Signature for the given builtin function."""
warnings.warn("inspect.Signature.from_builtin() is deprecated, "
- "use Signature.from_callable()", DeprecationWarning)
+ "use Signature.from_callable()",
+ DeprecationWarning, stacklevel=2)
return _signature_from_builtin(cls, func)
@classmethod
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list