diff Python/import.c @ 84003:82db02a2e023

Issue #18065: For frozen packages set __path__ to []. Previously __path__ was set to [__name__], but that could lead to bad results if someone managed to circumvent the frozen importer and somehow ended up with a finder that thought __name__ was a legit directory/location.
author Brett Cannon <brett@python.org>
date Fri, 31 May 2013 23:18:39 -0400
parents 5abe85aefe29
children 3a50025f1900
line wrap: on
line diff
--- a/Python/import.c	Fri May 31 18:57:45 2013 -0400
+++ b/Python/import.c	Fri May 31 23:18:39 2013 -0400
@@ -1107,19 +1107,17 @@
         goto err_return;
     }
     if (ispackage) {
-        /* Set __path__ to the package name */
+        /* Set __path__ to the empty list */
         PyObject *d, *l;
         int err;
         m = PyImport_AddModuleObject(name);
         if (m == NULL)
             goto err_return;
         d = PyModule_GetDict(m);
-        l = PyList_New(1);
+        l = PyList_New(0);
         if (l == NULL) {
             goto err_return;
         }
-        Py_INCREF(name);
-        PyList_SET_ITEM(l, 0, name);
         err = PyDict_SetItemString(d, "__path__", l);
         Py_DECREF(l);
         if (err != 0)