]> granicus.if.org Git - python/commitdiff
Fix a curious bug: statements like "import sys.time" would succeed,
authorGuido van Rossum <guido@python.org>
Tue, 19 May 1998 15:09:05 +0000 (15:09 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 19 May 1998 15:09:05 +0000 (15:09 +0000)
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.

Python/import.c

index 6c1050f0c696581cffd745251bd4f299f61259d8..40901180bf9ae03afc734362efab17a9992c897b 100644 (file)
@@ -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,