summaryrefslogtreecommitdiff
path: root/Python/import.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-01-09 19:56:33 +0000
committerChristian Heimes <christian@cheimes.de>2008-01-09 19:56:33 +0000
commit3403f1589d769a5596dfc261a9cab31b307fb059 (patch)
tree9e24a9ae128fda398b29cc839f05ae45a98d12ac /Python/import.c
parent195b883bb47a392ea8b92dccbca30ffcf1adecd3 (diff)
downloadcpython-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.c10
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;