summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/import.c b/Python/import.c
index adfd2cc..24df985 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1892,6 +1892,8 @@ find_module_path_list(PyObject *fullname, PyObject *name,
}
for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {
+ struct stat statbuf;
+
filemode = fdp->mode;
if (filemode[0] == 'U')
filemode = "r" PY_STDIOTEXTMODE;
@@ -1905,6 +1907,13 @@ find_module_path_list(PyObject *fullname, PyObject *name,
if (Py_VerboseFlag > 1)
PySys_FormatStderr("# trying %R\n", filename);
+ if (_Py_stat(filename, &statbuf) == 0 && /* it exists */
+ S_ISDIR(statbuf.st_mode)) /* it's a directory */
+ {
+ Py_DECREF(filename);
+ continue;
+ }
+
fp = _Py_fopen(filename, filemode);
if (fp == NULL) {
Py_DECREF(filename);