report caller's file:lineno of deprecated function instead of file:lineno of deprecated function

This commit is contained in:
Daniel Grana 2009-08-24 20:27:08 -03:00
parent 9bafa7325c
commit 9f1ed63763
1 changed files with 2 additions and 8 deletions

View File

@ -1,3 +1,4 @@
import sys
import warnings
from functools import wraps
@ -13,14 +14,7 @@ def deprecated(use_instead=None):
message = "Call to deprecated function %s." % func.__name__
if use_instead:
message += " Use %s instead." % use_instead
warnings.warn_explicit(message,
category=DeprecationWarning,
filename=func.func_code.co_filename,
lineno=func.func_code.co_firstlineno + 1,
registry=func.func_globals.setdefault('__warningregistry__', \
{}),
module_globals=func.func_globals)
warnings.warn(message, category=DeprecationWarning, stacklevel=2)
return func(*args, **kwargs)
return new_func
return wrapped