[Python-checkins] CVS: python/dist/src/Python import.c,2.175,2.175.2.1
Thomas Wouters
twouters@users.sourceforge.net
Wed, 23 May 2001 05:51:24 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv31242/Python
Modified Files:
Tag: release21-maint
import.c
Log Message:
Backport of Tim's checkin 2.177:
SF bug #417093: Case sensitive import: dir and .py file w/ same name
Directory containing
Spam.py
spam/__init__.py
Then "import Spam" caused a SystemError, because code checking for
the existence of "Spam/__init__.py" finds it on a case-insensitive
filesystem, but then bails because the directory it finds it in
doesn't match case, and then old code assumed that was still an error
even though it isn't anymore. Changed the code to just continue
looking in this case (instead of calling it an error). So
import Spam
and
import spam
both work now.
Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.175
retrieving revision 2.175.2.1
diff -C2 -r2.175 -r2.175.2.1
*** import.c 2001/04/13 17:50:20 2.175
--- import.c 2001/05/23 12:51:22 2.175.2.1
***************
*** 959,970 ****
and there's an __init__ module in that directory */
#ifdef HAVE_STAT
! if (stat(buf, &statbuf) == 0 &&
! S_ISDIR(statbuf.st_mode) &&
! find_init_module(buf)) {
! if (case_ok(buf, len, namelen, name))
! return &fd_package;
! else
! return NULL;
! }
#else
/* XXX How are you going to test for directories? */
--- 959,967 ----
and there's an __init__ module in that directory */
#ifdef HAVE_STAT
! if (stat(buf, &statbuf) == 0 && /* it exists */
! S_ISDIR(statbuf.st_mode) && /* it's a directory */
! find_init_module(buf) && /* it has __init__.py */
! case_ok(buf, len, namelen, name)) /* and case matches */
! return &fd_package;
#else
/* XXX How are you going to test for directories? */