[Python-checkins] cpython: Issue #14605: Insert to the front of sys.path_hooks instead of appending.

brett.cannon python-checkins at python.org
Thu Apr 26 02:19:04 CEST 2012


http://hg.python.org/cpython/rev/8dab93ec19de
changeset:   76562:8dab93ec19de
parent:      76548:a2cf07135e4f
user:        Brett Cannon <brett at python.org>
date:        Tue Apr 24 22:03:46 2012 -0400
summary:
  Issue #14605: Insert to the front of sys.path_hooks instead of appending.

files:
  Lib/test/test_importhooks.py     |  4 ++--
  Lib/test/test_threaded_import.py |  2 +-
  Python/import.c                  |  4 ++--
  3 files changed, 5 insertions(+), 5 deletions(-)


diff --git a/Lib/test/test_importhooks.py b/Lib/test/test_importhooks.py
--- a/Lib/test/test_importhooks.py
+++ b/Lib/test/test_importhooks.py
@@ -215,7 +215,7 @@
         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 @@
     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",
         )
diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py
--- a/Lib/test/test_threaded_import.py
+++ b/Lib/test/test_threaded_import.py
@@ -145,7 +145,7 @@
         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
diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -268,8 +268,8 @@
                     "# 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;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list