]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
SF bug #417093: Case sensitive import: dir and .py file w/ same name
authorTim Peters <tim.peters@gmail.com>
Sun, 29 Apr 2001 22:21:25 +0000 (22:21 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 29 Apr 2001 22:21:25 +0000 (22:21 +0000)
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.

Python/import.c

index 2c15d1050c84266d9c953d315c19962d0711d4e5..ef3e0e6d7a88e2aa3b941e8f7cf9ac7e15dc329e 100644 (file)
@@ -958,14 +958,11 @@ find_module(char *realname, PyObject *path, char *buf, size_t buflen,
                /* Check for package import (buf holds a directory name,
                   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;
-               }
+               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? */
 #ifdef RISCOS