]> granicus.if.org Git - python/commitdiff
bpo-33128 Fix duplicated call to importlib._install_external_importers (GH-6273)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 25 Apr 2018 02:48:04 +0000 (19:48 -0700)
committerGitHub <noreply@github.com>
Wed, 25 Apr 2018 02:48:04 +0000 (19:48 -0700)
External importers were being added in both phases of the import
system initialisation.

They're only supposed to be added in the second phase, after the
import machinery has been appropriately configured.
(cherry picked from commit 0977091dca59709864b14cfc129388f1f0de7bf7)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Lib/test/test_sys.py
Misc/NEWS.d/next/Core and Builtins/2018-04-24-22-31-04.bpo-33128.g2yLuf.rst [new file with mode: 0644]
Python/pylifecycle.c

index 6933b41353bd56386df4d3a955944f6d217afcc9..336ae447a8de5e5aad9c89886cd40a168f3d5200 100644 (file)
@@ -852,6 +852,9 @@ class SysModuleTest(unittest.TestCase):
         check(-1<<1000, [traceback[-1]])
         check(None, traceback)
 
+    def test_no_duplicates_in_meta_path(self):
+        self.assertEqual(len(sys.meta_path), len(set(sys.meta_path)))
+
 
 @test.support.cpython_only
 class SizeofTest(unittest.TestCase):
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-04-24-22-31-04.bpo-33128.g2yLuf.rst b/Misc/NEWS.d/next/Core and Builtins/2018-04-24-22-31-04.bpo-33128.g2yLuf.rst
new file mode 100644 (file)
index 0000000..66b98cd
--- /dev/null
@@ -0,0 +1,2 @@
+Fix a bug that causes PathFinder to appear twice on sys.meta_path. Patch by
+Pablo Galindo Salgado.
index 5db586e15dffc04437d5381f53ae9d037b2d6b41..2ef96f8d99ef2a60a50cfadc52d86dac47fcf217 100644 (file)
@@ -325,11 +325,6 @@ initimport(PyInterpreterState *interp, PyObject *sysmod)
 
     /* Install importlib as the implementation of import */
     value = PyObject_CallMethod(importlib, "_install", "OO", sysmod, impmod);
-    if (value != NULL) {
-        Py_DECREF(value);
-        value = PyObject_CallMethod(importlib,
-                                    "_install_external_importers", "");
-    }
     if (value == NULL) {
         PyErr_Print();
         return _Py_INIT_ERR("importlib install failed");