]> granicus.if.org Git - python/commitdiff
Issue #14605: Insert to the front of sys.path_hooks instead of appending.
authorBrett Cannon <brett@python.org>
Wed, 25 Apr 2012 02:03:46 +0000 (22:03 -0400)
committerBrett Cannon <brett@python.org>
Wed, 25 Apr 2012 02:03:46 +0000 (22:03 -0400)
Lib/test/test_importhooks.py
Lib/test/test_threaded_import.py
Python/import.c

index 7a256570cbb70e34cf7a4e96410a2562ab4bed8f..2a22d1a186c9d7cdb910d32384e30192c8b7fbca 100644 (file)
@@ -215,7 +215,7 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
         self.doTestImports(i)
 
     def testPathHook(self):
-        sys.path_hooks.append(PathImporter)
+        sys.path_hooks.insert(0, PathImporter)
         sys.path.append(test_path)
         self.doTestImports()
 
@@ -228,7 +228,7 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
     def testImpWrapper(self):
         i = ImpWrapper()
         sys.meta_path.append(i)
-        sys.path_hooks.append(ImpWrapper)
+        sys.path_hooks.insert(0, ImpWrapper)
         mnames = (
             "colorsys", "urllib.parse", "distutils.core", "sys",
         )
index 789920b7fa9e5407667934ca912ef31f4e9bae57..3faa1845e597867d0637de0e60369644ea00d62d 100644 (file)
@@ -145,7 +145,7 @@ class ThreadedImportTests(unittest.TestCase):
         def path_hook(path):
             finder.find_module('')
             raise ImportError
-        sys.path_hooks.append(path_hook)
+        sys.path_hooks.insert(0, path_hook)
         sys.meta_path.append(flushing_finder)
         try:
             # Flush the cache a first time
index ab320e523c23043d49c7ee01abe8c8e50444126d..8cf10e658c28c87877b4e207cae086856f14c03b 100644 (file)
@@ -268,8 +268,8 @@ _PyImportZip_Init(void)
                     "# can't import zipimport.zipimporter\n");
         }
         else {
-            /* sys.path_hooks.append(zipimporter) */
-            err = PyList_Append(path_hooks, zipimporter);
+            /* sys.path_hooks.insert(0, zipimporter) */
+            err = PyList_Insert(path_hooks, 0, zipimporter);
             Py_DECREF(zipimporter);
             if (err < 0) {
                 goto error;