Nested scopes resolution -- you can breathe again!

Robin Becker robin at jessikat.fsnet.co.uk
Wed Feb 28 05:27:55 EST 2001


In article <uu25fmwcq.fsf at ctwd0143.fitlinxx.com>, David Bolen
<db3l at fitlinxx.com> writes
>Robin Becker <robin at jessikat.fsnet.co.uk> writes:
....
>Well, but it doesn't have to be too much work.  I'm thinking of the
>specific ImportError of:
>
> "Module use of python15.dll conflicts with this version of Python."
>
>in which case you know that you have an old extension (which has to be
>on Python's sys.path somewhere), and that one of three things are
>true:
>
>1. The imported module directly depends on python15.dll (probably most
>   likely for C extension modules being directly imported, like zlib).
>2. The module you imported itself imports some other module with the
>   dependency - in that case you have the traceback showing which import
>   of which module failed, which reverts to the prior 1.
>3. The module has a Windows DLL dependency which eventually pulls in
>   python15.dll.  In this case, you know the top level module, so use
>   a standard windows tool like depends to check the dependencies.
>
....

I guess the 'import' of this is that I should be more specific in
trapping my import errors. Because zlib is often absent we have

try:
        import zlib
except ImportError:
        #other stuff
        ...

The catchall exception is my problem. I reckon the specific error trap
should be

except ImportError, 'No module named zlib'

but this dependency on the format of the message seems a bit fragile.

>Of course, none of this is to excuse the mess that is Windows DLL-land :-)

that is of course true ;(

>-- David

-- 
Robin Becker



More information about the Python-list mailing list