summaryrefslogtreecommitdiffstats
path: root/Lib/contextlib.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-04-30 21:08:42 (GMT)
committerGeorg Brandl <georg@python.org>2008-04-30 21:08:42 (GMT)
commit655fc7012abdf50e7f827762fb08760fe54b0094 (patch)
tree7ad036f9ba37cbe51a197a0a2d0ce3c0dd7fc647 /Lib/contextlib.py
parentd8f2d0bdb3d3b9abe53cda9add979e2fc4be7da0 (diff)
downloadcpython-655fc7012abdf50e7f827762fb08760fe54b0094.zip
cpython-655fc7012abdf50e7f827762fb08760fe54b0094.tar.gz
cpython-655fc7012abdf50e7f827762fb08760fe54b0094.tar.bz2
#1748: use functools.wraps instead of rolling own metadata update.
Diffstat (limited to 'Lib/contextlib.py')
-rw-r--r--Lib/contextlib.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py
index dbd1c57..c9793af 100644
--- a/Lib/contextlib.py
+++ b/Lib/contextlib.py
@@ -1,6 +1,7 @@
"""Utilities for with-statement contexts. See PEP 343."""
import sys
+from functools import wraps
__all__ = ["contextmanager", "nested", "closing"]
@@ -77,14 +78,9 @@ def contextmanager(func):
<cleanup>
"""
+ @wraps(func)
def helper(*args, **kwds):
return GeneratorContextManager(func(*args, **kwds))
- try:
- helper.__name__ = func.__name__
- helper.__doc__ = func.__doc__
- helper.__dict__ = func.__dict__
- except:
- pass
return helper