From a75c3cb55fd3a6f8a33a521c12f8d66649020ea8 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 12 Aug 2010 03:56:20 -0700 Subject: [PATCH] Fix lazyimport() to handle partially imported modules by creating proxies, instead of raising ImportError. --- pym/portage/proxy/lazyimport.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pym/portage/proxy/lazyimport.py b/pym/portage/proxy/lazyimport.py index b5d15931b..d878b7adc 100644 --- a/pym/portage/proxy/lazyimport.py +++ b/pym/portage/proxy/lazyimport.py @@ -199,7 +199,11 @@ def lazyimport(scope, *args): try: scope[alias] = getattr(already_imported, attr_name) except AttributeError: - raise ImportError('cannot import name %s' % attr_name) + # Apparently the target module is only partially + # imported, so create a proxy. + already_imported = None + scope[alias] = \ + _LazyImportFrom(scope, name, attr_name, alias) else: scope[alias] = \ _LazyImportFrom(scope, name, attr_name, alias) -- 2.26.2