mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
#1748: use functools.wraps instead of rolling own metadata update.
This commit is contained in:
parent
d8f2d0bdb3
commit
655fc7012a
1 changed files with 2 additions and 6 deletions
|
|
@ -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 some_generator(<arguments>):
|
|||
<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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue