Index: Python/import.c =================================================================== --- Python/import.c (revision 66835) +++ Python/import.c (working copy) @@ -3154,24 +3154,11 @@ return -1; } else { #ifndef RISCOS +#ifndef MS_WINDOWS struct stat statbuf; int rv; rv = stat(path, &statbuf); -#ifdef MS_WINDOWS - /* MS Windows stat() chokes on paths like C:\path\. Try to - * recover *one* time by stripping off a trailing slash or - * backslash. http://bugs.python.org/issue1293 - */ - if (rv != 0 && pathlen <= MAXPATHLEN && - (path[pathlen-1] == '/' || path[pathlen-1] == '\\')) { - char mangled[MAXPATHLEN+1]; - - strcpy(mangled, path); - mangled[pathlen-1] = '\0'; - rv = stat(mangled, &statbuf); - } -#endif if (rv == 0) { /* it exists */ if (S_ISDIR(statbuf.st_mode)) { @@ -3181,7 +3168,21 @@ return -1; } } -#else +#else /* MS_WINDOWS */ + DWORD rv; + + rv = GetFileAttributesA(path); + if (rv != -1) { + /* it exists */ + if (rv & FILE_ATTRIBUTE_DIRECTORY) { + /* it's a directory */ + PyErr_SetString(PyExc_ImportError, + "existing directory"); + return -1; + } + } +#endif +#else /* RISCOS */ if (object_exists(path)) { /* it exists */ if (isdir(path)) {