Index: Python/import.c =================================================================== --- Python/import.c (revision 58747) +++ Python/import.c (working copy) @@ -2921,6 +2921,7 @@ NullImporter_init(NullImporter *self, PyObject *args, PyObject *kwds) { char *path; + Py_ssize_t len, i; if (!_PyArg_NoKeywords("NullImporter()", kwds)) return -1; @@ -2929,13 +2930,26 @@ &path)) return -1; - if (strlen(path) == 0) { + len = strlen(path); + if (len == 0) { PyErr_SetString(PyExc_ImportError, "empty pathname"); return -1; } else { struct stat statbuf; int rv; + /* Remove trailing / and \. Windows' stat doesn't like them */ + for (i=len-1; i > 0; i--) { +#ifdef MS_WINDOWS + if (path[i] != '/' && path[i] != '\\') { +#else + if (path[i] != '/') { +#endif + break; + } + path[i] = '\0'; + } + rv = stat(path, &statbuf); if (rv == 0) { /* it exists */