Skip to content

Commit 5434efb

Browse files
author
georg.brandl
committed
#1748: use functools.wraps instead of rolling own metadata update.
git-svn-id: http://svn.python.org/projects/python/trunk@62605 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 2ff85d7 commit 5434efb

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Lib/contextlib.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Utilities for with-statement contexts. See PEP 343."""
22

33
import sys
4+
from functools import wraps
45

56
__all__ = ["contextmanager", "nested", "closing"]
67

@@ -77,14 +78,9 @@ def some_generator(<arguments>):
7778
<cleanup>
7879
7980
"""
81+
@wraps(func)
8082
def helper(*args, **kwds):
8183
return GeneratorContextManager(func(*args, **kwds))
82-
try:
83-
helper.__name__ = func.__name__
84-
helper.__doc__ = func.__doc__
85-
helper.__dict__ = func.__dict__
86-
except:
87-
pass
8884
return helper
8985

9086

0 commit comments

Comments
 (0)