Issue #21052: Don't raise ImportWarning for sys.meta_path or
sys.path_hooks when set to None during interpreter shutdown. Thanks to Martin Panter for the initial bug report.
This commit is contained in:
parent
1aa3cb6030
commit
5e8b04eefb
|
@ -1806,7 +1806,7 @@ class PathFinder:
|
|||
If 'hooks' is false then use sys.path_hooks.
|
||||
|
||||
"""
|
||||
if not sys.path_hooks:
|
||||
if sys.path_hooks is not None and not sys.path_hooks:
|
||||
_warnings.warn('sys.path_hooks is empty', ImportWarning)
|
||||
for hook in sys.path_hooks:
|
||||
try:
|
||||
|
@ -2095,7 +2095,7 @@ def _find_spec_legacy(finder, name, path):
|
|||
|
||||
def _find_spec(name, path, target=None):
|
||||
"""Find a module's loader."""
|
||||
if not sys.meta_path:
|
||||
if sys.meta_path is not None and not sys.meta_path:
|
||||
_warnings.warn('sys.meta_path is empty', ImportWarning)
|
||||
# We check sys.modules here for the reload case. While a passed-in
|
||||
# target will usually indicate a reload there is no guarantee, whereas
|
||||
|
|
|
@ -10,6 +10,9 @@ Release date: TBA
|
|||
Core and Builtins
|
||||
-----------------
|
||||
|
||||
- Issue #21052: Do not raise ImportWarning when sys.path_hooks or sys.meta_path
|
||||
are set to None.
|
||||
|
||||
- Issue #16518: Use 'bytes-like object required' in error messages that
|
||||
previously used the far more cryptic "'x' does not support the buffer
|
||||
protocol.
|
||||
|
|
|
@ -3210,12 +3210,13 @@ const unsigned char _Py_M__importlib[] = {
|
|||
80,97,116,104,70,105,110,100,101,114,46,105,110,118,97,108,
|
||||
105,100,97,116,101,95,99,97,99,104,101,115,99,2,0,0,
|
||||
0,0,0,0,0,3,0,0,0,12,0,0,0,67,0,0,
|
||||
0,115,91,0,0,0,116,0,0,106,1,0,115,25,0,116,
|
||||
2,0,106,3,0,100,1,0,116,4,0,131,2,0,1,120,
|
||||
0,115,107,0,0,0,116,0,0,106,1,0,100,1,0,107,
|
||||
9,0,114,41,0,116,0,0,106,1,0,12,114,41,0,116,
|
||||
2,0,106,3,0,100,2,0,116,4,0,131,2,0,1,120,
|
||||
59,0,116,0,0,106,1,0,68,93,44,0,125,2,0,121,
|
||||
14,0,124,2,0,124,1,0,131,1,0,83,87,113,35,0,
|
||||
4,116,5,0,107,10,0,114,78,0,1,1,1,119,35,0,
|
||||
89,113,35,0,88,113,35,0,87,100,2,0,83,100,2,0,
|
||||
14,0,124,2,0,124,1,0,131,1,0,83,87,113,51,0,
|
||||
4,116,5,0,107,10,0,114,94,0,1,1,1,119,51,0,
|
||||
89,113,51,0,88,113,51,0,87,100,1,0,83,100,1,0,
|
||||
83,41,3,122,113,83,101,97,114,99,104,32,115,101,113,117,
|
||||
101,110,99,101,32,111,102,32,104,111,111,107,115,32,102,111,
|
||||
114,32,97,32,102,105,110,100,101,114,32,102,111,114,32,39,
|
||||
|
@ -3223,15 +3224,15 @@ const unsigned char _Py_M__importlib[] = {
|
|||
73,102,32,39,104,111,111,107,115,39,32,105,115,32,102,97,
|
||||
108,115,101,32,116,104,101,110,32,117,115,101,32,115,121,115,
|
||||
46,112,97,116,104,95,104,111,111,107,115,46,10,10,32,32,
|
||||
32,32,32,32,32,32,122,23,115,121,115,46,112,97,116,104,
|
||||
95,104,111,111,107,115,32,105,115,32,101,109,112,116,121,78,
|
||||
32,32,32,32,32,32,78,122,23,115,121,115,46,112,97,116,
|
||||
104,95,104,111,111,107,115,32,105,115,32,101,109,112,116,121,
|
||||
41,6,114,7,0,0,0,218,10,112,97,116,104,95,104,111,
|
||||
111,107,115,114,166,0,0,0,114,167,0,0,0,114,168,0,
|
||||
0,0,114,153,0,0,0,41,3,114,8,1,0,0,114,35,
|
||||
0,0,0,90,4,104,111,111,107,114,4,0,0,0,114,4,
|
||||
0,0,0,114,5,0,0,0,218,11,95,112,97,116,104,95,
|
||||
104,111,111,107,115,10,7,0,0,115,16,0,0,0,0,7,
|
||||
9,1,16,1,16,1,3,1,14,1,13,1,12,2,122,22,
|
||||
25,1,16,1,16,1,3,1,14,1,13,1,12,2,122,22,
|
||||
80,97,116,104,70,105,110,100,101,114,46,95,112,97,116,104,
|
||||
95,104,111,111,107,115,99,2,0,0,0,0,0,0,0,3,
|
||||
0,0,0,11,0,0,0,67,0,0,0,115,94,0,0,0,
|
||||
|
@ -3732,28 +3733,29 @@ const unsigned char _Py_M__importlib[] = {
|
|||
17,95,102,105,110,100,95,115,112,101,99,95,108,101,103,97,
|
||||
99,121,39,8,0,0,115,8,0,0,0,0,3,18,1,12,
|
||||
1,4,1,114,103,1,0,0,99,3,0,0,0,0,0,0,
|
||||
0,9,0,0,0,26,0,0,0,67,0,0,0,115,25,1,
|
||||
0,0,116,0,0,106,1,0,115,25,0,116,2,0,106,3,
|
||||
0,100,1,0,116,4,0,131,2,0,1,124,0,0,116,0,
|
||||
0,9,0,0,0,26,0,0,0,67,0,0,0,115,41,1,
|
||||
0,0,116,0,0,106,1,0,100,1,0,107,9,0,114,41,
|
||||
0,116,0,0,106,1,0,12,114,41,0,116,2,0,106,3,
|
||||
0,100,2,0,116,4,0,131,2,0,1,124,0,0,116,0,
|
||||
0,106,5,0,107,6,0,125,3,0,120,234,0,116,0,0,
|
||||
106,1,0,68,93,219,0,125,4,0,116,6,0,131,0,0,
|
||||
143,90,0,1,121,13,0,124,4,0,106,7,0,125,5,0,
|
||||
87,110,51,0,4,116,8,0,107,10,0,114,132,0,1,1,
|
||||
87,110,51,0,4,116,8,0,107,10,0,114,148,0,1,1,
|
||||
1,116,9,0,124,4,0,124,0,0,124,1,0,131,3,0,
|
||||
125,6,0,124,6,0,100,2,0,107,8,0,114,128,0,119,
|
||||
50,0,89,110,19,0,88,124,5,0,124,0,0,124,1,0,
|
||||
124,2,0,131,3,0,125,6,0,87,100,2,0,81,88,124,
|
||||
6,0,100,2,0,107,9,0,114,50,0,124,3,0,12,114,
|
||||
9,1,124,0,0,116,0,0,106,5,0,107,6,0,114,9,
|
||||
125,6,0,124,6,0,100,1,0,107,8,0,114,144,0,119,
|
||||
66,0,89,110,19,0,88,124,5,0,124,0,0,124,1,0,
|
||||
124,2,0,131,3,0,125,6,0,87,100,1,0,81,88,124,
|
||||
6,0,100,1,0,107,9,0,114,66,0,124,3,0,12,114,
|
||||
25,1,124,0,0,116,0,0,106,5,0,107,6,0,114,25,
|
||||
1,116,0,0,106,5,0,124,0,0,25,125,7,0,121,13,
|
||||
0,124,7,0,106,10,0,125,8,0,87,110,22,0,4,116,
|
||||
8,0,107,10,0,114,241,0,1,1,1,124,6,0,83,89,
|
||||
113,13,1,88,124,8,0,100,2,0,107,8,0,114,2,1,
|
||||
124,6,0,83,124,8,0,83,113,50,0,124,6,0,83,113,
|
||||
50,0,87,100,2,0,83,100,2,0,83,41,3,122,23,70,
|
||||
8,0,107,10,0,114,1,1,1,1,1,124,6,0,83,89,
|
||||
113,29,1,88,124,8,0,100,1,0,107,8,0,114,18,1,
|
||||
124,6,0,83,124,8,0,83,113,66,0,124,6,0,83,113,
|
||||
66,0,87,100,1,0,83,100,1,0,83,41,3,122,23,70,
|
||||
105,110,100,32,97,32,109,111,100,117,108,101,39,115,32,108,
|
||||
111,97,100,101,114,46,122,22,115,121,115,46,109,101,116,97,
|
||||
95,112,97,116,104,32,105,115,32,101,109,112,116,121,78,41,
|
||||
111,97,100,101,114,46,78,122,22,115,121,115,46,109,101,116,
|
||||
97,95,112,97,116,104,32,105,115,32,101,109,112,116,121,41,
|
||||
11,114,7,0,0,0,218,9,109,101,116,97,95,112,97,116,
|
||||
104,114,166,0,0,0,114,167,0,0,0,114,168,0,0,0,
|
||||
114,73,0,0,0,114,99,1,0,0,114,10,1,0,0,114,
|
||||
|
@ -3763,7 +3765,7 @@ const unsigned char _Py_M__importlib[] = {
|
|||
10,1,0,0,114,176,0,0,0,114,177,0,0,0,114,206,
|
||||
0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,
|
||||
0,0,218,10,95,102,105,110,100,95,115,112,101,99,48,8,
|
||||
0,0,115,48,0,0,0,0,2,9,1,16,4,15,1,16,
|
||||
0,0,115,48,0,0,0,0,2,25,1,16,4,15,1,16,
|
||||
1,10,1,3,1,13,1,13,1,18,1,12,1,8,2,24,
|
||||
1,12,2,22,1,13,1,3,1,13,1,13,4,9,2,12,
|
||||
1,4,2,7,2,8,2,114,105,1,0,0,99,3,0,0,
|
||||
|
|
Loading…
Reference in New Issue