Windows DLL import error (bug?)

Tim Peters tim.one at home.com
Fri Aug 10 21:47:31 CEST 2001


[Campbell]
> I am using Windows NT 4.0 with Python 2.1.
>
> I have a DLL called _starla.dll,

It appears from the following that it was actually named _STARLA.DLL.

> and the words 'import _starla' at the top of a script in the same
directory.
> This of course works just fine.  This morning, after I rebuilt the dll, I
> suddenly found an ImportError, and python could not find the dll.
>
> Viewing the directory through an smbfs mount on a Linux machine, I
> notice that the file (according to ls) is called _STARLA.DLL.

Why would you have to go thru all that to find out the name?  A "dir" in a
DOS box should have shown you the same thing.  Explorer should have shown it
to you too, assuming you set its "Allow all uppercase names" option.

> renaming the file to _starla.dll fixed my problem, though it took a very
> long time to figure out.

Whenever you have an import problem, run Python with the -v switch (or
even -vv).  That displays a lot of info about what Python is trying to do.

> If I rename the file to _STARLA.DLL, the error returns.
>
> I thought windows was case insensitive?

While NTFS is case-preserving but case-insensitive, Python switched to
case-sensitive imports on all platforms; see PEP 235 for details:

    http://python.sourceforge.net/peps/pep-0235.html

If you can't keep your cases straight, you can set the envar PYTHONCASEOK,
and then Python will ignore import case on Windows.  Not recommended,
though.  Also move to the 2.1 bugfix release, 2.1.1 -- IIRC, it fixed some
endcase import glitches on Windows.






More information about the Python-list mailing list