From: Georg Brandl Date: Wed, 30 Apr 2008 21:08:42 +0000 (+0000) Subject: #1748: use functools.wraps instead of rolling own metadata update. X-Git-Tag: v2.6a3~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=655fc7012abdf50e7f827762fb08760fe54b0094;p=python #1748: use functools.wraps instead of rolling own metadata update. --- diff --git a/Lib/contextlib.py b/Lib/contextlib.py index dbd1c5744d..c9793af6ef 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): """ + @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