[Python-checkins] r62605 - python/trunk/Lib/contextlib.py

georg.brandl python-checkins at python.org
Wed Apr 30 23:08:43 CEST 2008


Author: georg.brandl
Date: Wed Apr 30 23:08:42 2008
New Revision: 62605
Log:
#1748: use functools.wraps instead of rolling own metadata update.
Modified:
 python/trunk/Lib/contextlib.py
Modified: python/trunk/Lib/contextlib.py
==============================================================================
--- python/trunk/Lib/contextlib.py	(original)
+++ python/trunk/Lib/contextlib.py	Wed Apr 30 23:08:42 2008
@@ -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 @@
 <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
 
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /