[mod_python] import_module is case sensitive even if the OS isn't

Graham Dumpleton graham.dumpleton at gmail.com
Mon May 14 06:49:43 EDT 2007

Anyone else got any comments on whether normcase() should be applied?
I'm don't use Windows so don't really know what is best.

---------- Forwarded message ----------
From: Simon Holness <simon.holness at gmail.com>
Date: 14-May-2007 20:24
Subject: Re: [mod_python] import_module is case sensitive even if the OS isn't
To: Graham Dumpleton <graham.dumpleton at gmail.com>

On 5/12/07, Graham Dumpleton <graham.dumpleton at gmail.com> wrote:
> The _check_directory() method will also need to be changed in some way
> to ensure the integrity checks work also. Ie.
>     if directory in sys.path:
> need to change to:
>     if directory in map(os.path.normcase, sys.path):
> What happens though if Windows is being asked to mount a remote file
> system which is case sensitive and files were being loaded from there.
> Are files on such a file system seen as case sensitive. If they are
> then the changes can't be made. Can anyone comment on the remote file
> system example and how case is handled for files from that?

Windows copes really badly, is the short answer.
If you smb mount a case-sensitive filesystem and have a clash of paths
based on differeing case alone, windows will only (afaict) allow you
to navigate into the lowercase version.

E.g. if I mount

I can never get windows to find file2 ... listing /work/Test gives file1.

> Also, are there any native file systems on Windows that are case
> sensitive. On Mac OS X the default file system is case insensitive,
> but one can use case sensitive local file systems as well.

How does normcase work in this situation?
I assume its behaviour is based on the sensitivity of the OS not the
filesystem in question? So for OS X I presume normcase leaves paths

> Finally, with such a change log messages and error pages are going to
> now show lower case paths which may confuse people if the original
> path used mixed case.

True. Only on case-insensitive OS's of course, where it shouldn't be a
real problem.

> It is because of these issues that I may have originally not applied
> os.path.normcase() to paths and basically taken the viewpoint that
> users should just get their paths consistent in the first place as too
> hard otherwise.

Fair point, but unfortunately paths aren't always constructed in
simple ways. For example, while windows is case-insensitive for path
navigation it is case sensitive for path generation and reporting. So
it's not a matter of the user being consistent with themselves, but
with the OS (and potentially any other libraries) they're using. In
the case I ran into, for example, I'd used lowercase for the drive
letter in one place and this differed from the upper case which
windows uses (from an auto-generated path I was using in a different
location). Luckily I was looking into the subject of module loading
and so noticed the path difference in the apache log notices, but I'd
guess most people wouldn't spot this easily.

I can certainly see your point. Maybe, if you're not keen on the code
change being made, just a documentation change to note that you must
be consistent with the OS with respect to case or it may load the same
file as multiple modules?


More information about the Mod_python mailing list