From: Zac Medico Date: Thu, 12 Aug 2010 10:56:20 +0000 (-0700) Subject: Fix lazyimport() to handle partially imported modules by creating X-Git-Tag: v2.2_rc68~263 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a75c3cb55fd3a6f8a33a521c12f8d66649020ea8;p=portage.git Fix lazyimport() to handle partially imported modules by creating proxies, instead of raising ImportError. --- 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)