diff Python/import.c @ 44614:dc9d95b717c5 legacy-trunk

Fixed #1776. __import__() no longer imports modules by file name
author Christian Heimes <christian@cheimes.de>
date Wed, 09 Jan 2008 19:56:33 +0000
parents 132d908471c8
children 9639a73afa47
line wrap: on
line diff
--- a/Python/import.c	Wed Jan 09 14:46:10 2008 +0000
+++ b/Python/import.c	Wed Jan 09 19:56:33 2008 +0000
@@ -2055,6 +2055,16 @@
 	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;