[PEAK] invalid fromlist in importString

Phillip J. Eby pje at telecommunity.com
Sat Nov 22 11:19:48 EST 2003


At 05:07 PM 11/22/03 +0200, alexander smishlajev wrote:
>hello!
>
>importString does not play well with imputil: for the first path 
>component, importString calls __import__() with fromlist that is not 
>expected to exist.  standard implementation seems to ignore the fromlist 
>argument, but imputil raises ImportError if an item in fromlist does not exist.
>
>may [part] be replaced with ('*',)?  perhaps for the first part only?

It seems to work okay with the test suite.  In fact, replacing [part] with 
'*' appears to work regardless of whether it's the first part.

Looking at imputil, however, it appears to want to actually import the 
listed parts.  If we use '*', it will try to import all 
subpackages/submodules listed by a package's '__all__' attribute, which 
might not be what we want.

So, after a little thought and looking at imputil, I think that [part] 
should be replaced by ['__name__'].  All package and module objects have a 
__name__ attribute, so imputil should behave sensibly in that case.  I've 
just checked in the change; please let me know how if there's still a problem.




More information about the PEAK mailing list