Don't fail in the face of a lacking attribute when wrapping a

function.
This commit is contained in:
Brett Cannon 2012-02-08 18:44:14 -05:00
parent 81a1fa5c77
commit 8490fab4ad
1 changed files with 2 additions and 1 deletions

View File

@ -170,6 +170,7 @@ def _write_atomic(path, data):
def _wrap(new, old):
"""Simple substitute for functools.wraps."""
for replace in ['__module__', '__name__', '__qualname__', '__doc__']:
if hasattr(old, replace):
setattr(new, replace, getattr(old, replace))
new.__dict__.update(old.__dict__)