Fix python 3 support

Fix #94
pull/66/head
Raphaël Vinot 2017-03-31 11:44:48 +02:00
parent 6b530db32d
commit 142566df4d
1 changed files with 14 additions and 6 deletions

View File

@ -49,12 +49,20 @@ def deprecated(func):
@functools.wraps(func)
def new_func(*args, **kwargs):
if sys.version_info < (3, 0):
warnings.warn_explicit(
"Call to deprecated function {}.".format(func.__name__),
category=DeprecationWarning,
filename=func.func_code.co_filename,
lineno=func.func_code.co_firstlineno + 1
)
else:
warnings.warn_explicit(
"Call to deprecated function {}.".format(func.__name__),
category=DeprecationWarning,
filename=func.__code__.co_filename,
lineno=func.__code__.co_firstlineno + 1
)
return func(*args, **kwargs)
return new_func