From d0217d7b8709017ed91d28a0fae4139bb2cd25a2 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Mon, 3 Sep 2012 22:54:59 -0400 Subject: [PATCH] Ensure lazy-loading works with subpackages. --- earwigbot/lazy.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/earwigbot/lazy.py b/earwigbot/lazy.py index f9214e0..b123e3c 100644 --- a/earwigbot/lazy.py +++ b/earwigbot/lazy.py @@ -60,6 +60,8 @@ class _LazyModule(type): parents = (ModuleType,) klass = type.__new__(cls, "module", parents, attributes) sys.modules[name] = klass(name) + if "." in name: # Also ensure the parent exists + _LazyModule(name.rsplit(".", 1)[0]) return sys.modules[name] finally: release_lock()