(original) (raw)

changeset: 76562:8dab93ec19de parent: 76548:a2cf07135e4f user: Brett Cannon brett@python.org date: Tue Apr 24 22:03:46 2012 -0400 files: Lib/test/test_importhooks.py Lib/test/test_threaded_import.py Python/import.c description: Issue #14605: Insert to the front of sys.path_hooks instead of appending. diff -r a2cf07135e4f -r 8dab93ec19de Lib/test/test_importhooks.py --- a/Lib/test/test_importhooks.py Wed Apr 25 02:31:37 2012 +0200 +++ b/Lib/test/test_importhooks.py Tue Apr 24 22:03:46 2012 -0400 @@ -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 -r a2cf07135e4f -r 8dab93ec19de Lib/test/test_threaded_import.py --- a/Lib/test/test_threaded_import.py Wed Apr 25 02:31:37 2012 +0200 +++ b/Lib/test/test_threaded_import.py Tue Apr 24 22:03:46 2012 -0400 @@ -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 -r a2cf07135e4f -r 8dab93ec19de Python/import.c --- a/Python/import.c Wed Apr 25 02:31:37 2012 +0200 +++ b/Python/import.c Tue Apr 24 22:03:46 2012 -0400 @@ -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; /brett@python.org