Set stacklevel to 2 to get more accurate warning messages from deprecated functions.

This commit is contained in:
Berker Peksag 2015-05-21 23:40:54 +03:00
parent d854aacaa9
commit b560158622
1 changed files with 4 additions and 2 deletions

View File

@ -2662,7 +2662,8 @@ class Signature:
"""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 @@ class Signature:
"""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