From 8490fab4add07e4db261053fb420c2e411f82026 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 8 Feb 2012 18:44:14 -0500 Subject: [PATCH] Don't fail in the face of a lacking attribute when wrapping a function. --- Lib/importlib/_bootstrap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index f0de77bc62d..e2dd0869114 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -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__)