diff options
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Python/import.c b/Python/import.c index 6500f23bc8..f9d4246a2b 100644 --- a/Python/import.c +++ b/Python/import.c @@ -2000,6 +2000,16 @@ import_module_level(char *name, PyObject *globals, PyObject *locals, Py_ssize_t buflen = 0; PyObject *parent, *head, *next, *tail; + if (strchr(name, '/') != NULL +#ifdef MS_WINDOWS + || strchr(name, '\\') != NULL +#endif + ) { + PyErr_SetString(PyExc_ImportError, + "Import by filename is not supported."); + return NULL; + } + parent = get_parent(globals, buf, &buflen, level); if (parent == NULL) return NULL; |