[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Lib/test test___all__.py,1.3,1.4

Guido van Rossum guido@digicool.com
Tue, 23 Jan 2001 22:11:30 -0500


>     Guido> - Use "exec ... in dict" to avoid having to walk on eggshells;
>     Guido>   locals no don't have to start with underscore.
> 
> Thanks.  I have just been incredibly short on time lately.

You're welcome.

>     Guido> - Only test dbhash if bsddb can be imported.  (Wonder if there
>     Guido>   are more like this?)
> 
> Alpha testing should pick those up, yes? ;-)

Yes. :-)

>     Guido> ! try:
>     Guido> !     import bsddb
>     Guido> ! except ImportError:
>     Guido> !     if verbose:
>     Guido> !         print "can't import bsddb, so skipping dbhash"
>     Guido> ! else:
>     Guido> !     check_all("dbhash")
> 
> Instead of having to know that dbhash includes bsddb, shouldn't dbhash be
> the module that's imported here?

I think I saw a complaint about this that specifically said that when
dbhash is imported when bsddb can't be imported, an incomplete dbhash
is left behind in sys.modules, and then a second import of dbhash will
succeed -- but of course it will define no objects.  Since dbhash may
be imported elsewhere, testing for bsddb is safer.

--Guido van Rossum (home page: http://www.python.org/~guido/)