diff options
author | Christian Heimes <christian@cheimes.de> | 2008-01-09 19:56:33 +0000 |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-01-09 19:56:33 +0000 |
commit | 3403f1589d769a5596dfc261a9cab31b307fb059 (patch) | |
tree | 9e24a9ae128fda398b29cc839f05ae45a98d12ac /Python/import.c | |
parent | 195b883bb47a392ea8b92dccbca30ffcf1adecd3 (diff) | |
download | cpython-git-3403f1589d769a5596dfc261a9cab31b307fb059.tar.gz |
Fixed #1776. __import__() no longer imports modules by file name
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 d9550f5c68..71ec20a252 100644 --- a/Python/import.c +++ b/Python/import.c @@ -2055,6 +2055,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; |