summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-05-19 15:09:05 (GMT)
committerGuido van Rossum <guido@python.org>1998-05-19 15:09:05 (GMT)
commit9c0afe5dc71bb072f7aa471b572799fabda52e40 (patch)
tree825331800729ecde5fe4bf76c203bbdcdb646d81 /Python
parentedde1501272e18e7fa072b851c1f505296a7dc90 (diff)
downloadcpython-9c0afe5dc71bb072f7aa471b572799fabda52e40.zip
cpython-9c0afe5dc71bb072f7aa471b572799fabda52e40.tar.gz
cpython-9c0afe5dc71bb072f7aa471b572799fabda52e40.tar.bz2
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.
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/Python/import.c b/Python/import.c
index 6c1050f..4090118 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1664,9 +1664,16 @@ import_submodule(mod, subname, fullname)
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,