summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichele Simionato <michele.simionato@gmail.com>2015-07-19 07:36:08 +0200
committerMichele Simionato <michele.simionato@gmail.com>2015-07-19 07:36:08 +0200
commit79c669ce71afcd70b49344823b5ccc8a61023f98 (patch)
tree804468b4ce1810ba0502a5b53a60c8815711b12f /src
parentda7b6d12e18d4d123db61a74c933d5106db59465 (diff)
downloadpython-decorator-git-79c669ce71afcd70b49344823b5ccc8a61023f98.tar.gz
Unified the documentation for Python 2 and 3
Diffstat (limited to 'src')
-rw-r--r--src/decorator.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/decorator.py b/src/decorator.py
index 2e14027..96de525 100644
--- a/src/decorator.py
+++ b/src/decorator.py
@@ -244,7 +244,7 @@ def decorator(caller, func=None):
# ####################### contextmanager ####################### #
def __call__(self, func):
- 'Context manager decorator'
+ """Context manager decorator"""
return FunctionMaker.create(
func, "with _self_: return _func_(%(shortsignature)s)",
dict(_self_=self, _func_=func), __wrapped__=func)
@@ -258,17 +258,11 @@ try: # Python >= 3.2
except ImportError: # Python >= 2.5
- try:
- from contextlib import GeneratorContextManager
- except ImportError: # Python 2.4
- class ContextManager(object):
- def __init__(self, g, *a, **k):
- raise RuntimeError(
- 'You cannot used contextmanager in Python 2.4!')
- else:
- class ContextManager(GeneratorContextManager):
- def __init__(self, g, *a, **k):
- return GeneratorContextManager.__init__(self, g(*a, **k))
- __call__ = __call__
+ from contextlib import GeneratorContextManager
+
+ class ContextManager(GeneratorContextManager):
+ def __init__(self, g, *a, **k):
+ return GeneratorContextManager.__init__(self, g(*a, **k))
+ __call__ = __call__
contextmanager = decorator(ContextManager)