summaryrefslogtreecommitdiff
path: root/deprecation.py
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2010-01-25 19:21:43 +0100
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2010-01-25 19:21:43 +0100
commitb5acd216cd400458a657ad726bc234e5d70541a4 (patch)
treebd8b9c85a6b505810ef52d093faf976be7e468ea /deprecation.py
parent26475801d2d4ab8b4a5a8560a014398ec4e549d3 (diff)
downloadlogilab-common-b5acd216cd400458a657ad726bc234e5d70541a4.tar.gz
deprecation: deprecated now takes an optional 'stacklevel' argument, default to 2
Diffstat (limited to 'deprecation.py')
-rw-r--r--deprecation.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/deprecation.py b/deprecation.py
index 154ae7c..d6cd86c 100644
--- a/deprecation.py
+++ b/deprecation.py
@@ -58,7 +58,7 @@ def class_moved(new_class, old_name=None, message=None):
old_name, new_class.__module__, new_class.__name__)
return class_renamed(old_name, new_class, message)
-def deprecated(reason=None):
+def deprecated(reason=None, stacklevel=2):
"""Decorator that raises a DeprecationWarning to print a message
when the decorated function is called.
"""
@@ -67,7 +67,7 @@ def deprecated(reason=None):
if '%s' in message:
message = message % func.func_name
def wrapped(*args, **kwargs):
- warn(message, DeprecationWarning, stacklevel=2)
+ warn(message, DeprecationWarning, stacklevel=stacklevel)
return func(*args, **kwargs)
return wrapped
return deprecated_decorator