mirror of
https://github.com/python/cpython.git
synced 2025-07-28 05:34:31 +00:00
Fixed #1776. __import__() no longer imports modules by file name
This commit is contained in:
parent
195b883bb4
commit
3403f1589d
3 changed files with 25 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue