Fix function code.

This commit is contained in:
Stefan van der Walt
2013-06-28 15:09:58 -05:00
parent b04c3282bf
commit 84615478e4
+5 -2
View File
@@ -1,6 +1,8 @@
import warnings
import functools
from . import six
__all__ = ['deprecated']
@@ -35,10 +37,11 @@ class deprecated(object):
@functools.wraps(func)
def wrapped(*args, **kwargs):
if self.behavior == 'warn':
func_code = six.get_function_code(func)
warnings.warn_explicit(msg,
category=DeprecationWarning,
filename=func.func_code.co_filename,
lineno=func.func_code.co_firstlineno + 1)
filename=func_code.co_filename,
lineno=func_code.co_firstlineno + 1)
elif self.behavior == 'raise':
raise DeprecationWarning(msg)
return func(*args, **kwargs)