Commit 655fc701 authored by Georg Brandl's avatar Georg Brandl

#1748: use functools.wraps instead of rolling own metadata update.

parent d8f2d0bd
"""Utilities for with-statement contexts. See PEP 343.""" """Utilities for with-statement contexts. See PEP 343."""
import sys import sys
from functools import wraps
__all__ = ["contextmanager", "nested", "closing"] __all__ = ["contextmanager", "nested", "closing"]
...@@ -77,14 +78,9 @@ def contextmanager(func): ...@@ -77,14 +78,9 @@ def contextmanager(func):
<cleanup> <cleanup>
""" """
@wraps(func)
def helper(*args, **kwds): def helper(*args, **kwds):
return GeneratorContextManager(func(*args, **kwds)) return GeneratorContextManager(func(*args, **kwds))
try:
helper.__name__ = func.__name__
helper.__doc__ = func.__doc__
helper.__dict__ = func.__dict__
except:
pass
return helper return helper
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment