mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
Issue #14605: Insert to the front of sys.path_hooks instead of appending.
This commit is contained in:
parent
4fe29c9657
commit
8923a4d4c5
3 changed files with 5 additions and 5 deletions
|
@ -215,7 +215,7 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
|
||||||
self.doTestImports(i)
|
self.doTestImports(i)
|
||||||
|
|
||||||
def testPathHook(self):
|
def testPathHook(self):
|
||||||
sys.path_hooks.append(PathImporter)
|
sys.path_hooks.insert(0, PathImporter)
|
||||||
sys.path.append(test_path)
|
sys.path.append(test_path)
|
||||||
self.doTestImports()
|
self.doTestImports()
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
|
||||||
def testImpWrapper(self):
|
def testImpWrapper(self):
|
||||||
i = ImpWrapper()
|
i = ImpWrapper()
|
||||||
sys.meta_path.append(i)
|
sys.meta_path.append(i)
|
||||||
sys.path_hooks.append(ImpWrapper)
|
sys.path_hooks.insert(0, ImpWrapper)
|
||||||
mnames = (
|
mnames = (
|
||||||
"colorsys", "urllib.parse", "distutils.core", "sys",
|
"colorsys", "urllib.parse", "distutils.core", "sys",
|
||||||
)
|
)
|
||||||
|
|
|
@ -145,7 +145,7 @@ class ThreadedImportTests(unittest.TestCase):
|
||||||
def path_hook(path):
|
def path_hook(path):
|
||||||
finder.find_module('')
|
finder.find_module('')
|
||||||
raise ImportError
|
raise ImportError
|
||||||
sys.path_hooks.append(path_hook)
|
sys.path_hooks.insert(0, path_hook)
|
||||||
sys.meta_path.append(flushing_finder)
|
sys.meta_path.append(flushing_finder)
|
||||||
try:
|
try:
|
||||||
# Flush the cache a first time
|
# Flush the cache a first time
|
||||||
|
|
|
@ -268,8 +268,8 @@ _PyImportZip_Init(void)
|
||||||
"# can't import zipimport.zipimporter\n");
|
"# can't import zipimport.zipimporter\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* sys.path_hooks.append(zipimporter) */
|
/* sys.path_hooks.insert(0, zipimporter) */
|
||||||
err = PyList_Append(path_hooks, zipimporter);
|
err = PyList_Insert(path_hooks, 0, zipimporter);
|
||||||
Py_DECREF(zipimporter);
|
Py_DECREF(zipimporter);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue