Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 8374:a1bfe5bc6d8e legacy-trunk
Fix a curious bug: statements like "import sys.time" would succeed,
because the path through the code would notice that sys.__path__ did
not exist and it would fall back to the default path (builtins +
sys.path) instead of failing). No longer.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 19 May 1998 15:09:05 +0000 |
| parents | 7a1e7da922f8 |
| children | 35a2151fb1c3 |
line wrap: on
line diff
--- a/Python/import.c Tue May 19 15:04:21 1998 +0000 +++ b/Python/import.c Tue May 19 15:09:05 1998 +0000 @@ -1664,9 +1664,16 @@ struct filedescr *fdp; FILE *fp = NULL; - path = PyObject_GetAttrString(mod, "__path__"); - if (path == NULL) - PyErr_Clear(); + if (mod == Py_None) + path = NULL; + else { + path = PyObject_GetAttrString(mod, "__path__"); + if (path == NULL) { + PyErr_Clear(); + Py_INCREF(Py_None); + return Py_None; + } + } buf[0] = '\0'; fdp = find_module(subname, path,
