From 142566df4d9512b5b3678b27de25fc3a6369693e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 31 Mar 2017 11:44:48 +0200 Subject: [PATCH] Fix python 3 support Fix #94 --- pymisp/api.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pymisp/api.py b/pymisp/api.py index 73980de..2eddc1d 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -49,12 +49,20 @@ def deprecated(func): @functools.wraps(func) def new_func(*args, **kwargs): - 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 - ) + 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