[Python-Dev] Case-sensitive import

Tim Peters tim.one@home.com
Wed, 28 Feb 2001 00:48:57 -0500


Here's the checkin comment for rev 2.163 of import.c:

"""
Implement PEP 235:  Import on Case-Insensitive Platforms.
    http://python.sourceforge.net/peps/pep-0235.html

Renamed check_case to case_ok.  Substantial code rearrangement to get
this stuff in one place in the file.  Innermost loop of find_module()
now much simpler and #ifdef-free, and I want to keep it that way (it's
bad enough that the innermost loop is itself still in an #ifdef!).

Windows semantics tested and are fine.

Jason, Cygwin *should* be fine if and only if what you did for check_case()
before still "works".

Jack, the semantics on your flavor of Mac have definitely changed (see
the PEP), and need to be tested.  The intent is that your flavor of Mac
now work the same as everything else in the "lower left" box, including
respecting PYTHONCASEOK.  There is a non-zero chance that I already changed
the "#ifdef macintosh" code correctly to achieve that.

Steven, sorry, you did the most work here so far but you got screwed the
worst.  Happy to work with you on repairing it, but I don't understand
anything about all your Mac variants and don't have time to learn before the
beta.  We need to add another branch (or two, three, ...?) inside case_ok for
you.  But we should not need to change anything else.
"""

Someone please check Linux etc too, although everything that doesn't match
one of these #ifdef's:

#if defined(MS_WIN32) || defined(__CYGWIN__)
#elif defined(DJGPP)
#elif defined(macintosh)

*should* act as if the platform filesystem were case-sensitive (i.e., that if
fopen() succeeds, the case must match already and so there's no need for any
more work to check that).

Jason, if Cygwin is broken, please coordinate with Steven since you two
appear to have similar problems then.

[Steven]
> __MACH__ is predefined, meaning mach system calls are supported, and
> __APPLE__ is predefined -- I think it means it's Apple's compiler. So:
>
> 	#if defined(__MACH__) && defined(__APPLE__)
>
> ought to uniquely identify Darwin, at least until Apple does another OS.
>
> ( Maybe it would be cleaner to have config add -DDarwin switches -- or
> if you want to get general -D$MACHDEP -- except that I don't think all
> the values of MACHDEP will parse as symbols. )

This is up to you.  I'm sorry to have broken your old code, but Barry should
not have accepted it to begin with <wink>.  Speaking of which,

[Barry]
>     SDM> Yes. Barry added the _DIRENT_HAVE_D_NAMELINE to handle a
>     SDM> difference in the linux dirent structs.
>
> Actually, my Linux distro's dirent.h has almost the same test on
> _DIRENT_HAVE_D_NAMLEN (sic) -- which looking again now at import.c
> it's obvious I misspelled it!
>
> Tim, if you clean this code up and decide to continue to use the
> d_namlen slot, please fix the macro test.

For now, I didn't change anything in the MatchFilename function, but put the
entire thing in an "#if 0" block with an "XXX" comment, to make it easy for
Steven and/or Jason to get at that source if one or both decide their
platforms still need something like that.

If they do, I'll double-check that this #define is spelled correctly when
they check in their changes; else I'll delete that block before the release.

Aren't release crunches great?  Afraid they're infectious <0.5 wink>.