]> granicus.if.org Git - python/commitdiff
Don't fail in the face of a lacking attribute when wrapping a
authorBrett Cannon <brett@python.org>
Wed, 8 Feb 2012 23:44:14 +0000 (18:44 -0500)
committerBrett Cannon <brett@python.org>
Wed, 8 Feb 2012 23:44:14 +0000 (18:44 -0500)
function.

Lib/importlib/_bootstrap.py

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