mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #25791: Warn when __package__ != __spec__.parent.
In a previous change, __spec__.parent was prioritized over __package__. That is a backwards-compatibility break, but we do eventually want __spec__ to be the ground truth for module details. So this change reverts the change in semantics and instead raises an ImportWarning when __package__ != __spec__.parent to give people time to adjust to using spec objects.
This commit is contained in:
parent
52c854a838
commit
849113af6b
8 changed files with 184 additions and 121 deletions
|
@ -1787,43 +1787,52 @@ const unsigned char _Py_M__importlib[] = {
|
|||
115,116,228,3,0,0,115,34,0,0,0,0,10,15,1,12,
|
||||
1,12,1,13,1,15,1,16,1,13,1,15,1,21,1,3,
|
||||
1,17,1,18,4,21,1,15,1,3,1,26,1,114,195,0,
|
||||
0,0,99,1,0,0,0,0,0,0,0,3,0,0,0,5,
|
||||
0,0,0,67,0,0,0,115,128,0,0,0,124,0,0,106,
|
||||
0,0,100,1,0,131,1,0,125,1,0,124,1,0,100,2,
|
||||
0,107,9,0,114,34,0,124,1,0,106,1,0,83,124,0,
|
||||
0,106,0,0,100,3,0,131,1,0,125,2,0,124,2,0,
|
||||
100,2,0,107,8,0,114,124,0,116,2,0,106,3,0,100,
|
||||
4,0,116,4,0,100,5,0,100,6,0,131,2,1,1,124,
|
||||
0,0,100,7,0,25,125,2,0,100,8,0,124,0,0,107,
|
||||
7,0,114,124,0,124,2,0,106,5,0,100,9,0,131,1,
|
||||
0,100,10,0,25,125,2,0,124,2,0,83,41,11,122,167,
|
||||
67,97,108,99,117,108,97,116,101,32,119,104,97,116,32,95,
|
||||
95,112,97,99,107,97,103,101,95,95,32,115,104,111,117,108,
|
||||
100,32,98,101,46,10,10,32,32,32,32,95,95,112,97,99,
|
||||
107,97,103,101,95,95,32,105,115,32,110,111,116,32,103,117,
|
||||
97,114,97,110,116,101,101,100,32,116,111,32,98,101,32,100,
|
||||
101,102,105,110,101,100,32,111,114,32,99,111,117,108,100,32,
|
||||
98,101,32,115,101,116,32,116,111,32,78,111,110,101,10,32,
|
||||
32,32,32,116,111,32,114,101,112,114,101,115,101,110,116,32,
|
||||
116,104,97,116,32,105,116,115,32,112,114,111,112,101,114,32,
|
||||
118,97,108,117,101,32,105,115,32,117,110,107,110,111,119,110,
|
||||
46,10,10,32,32,32,32,114,95,0,0,0,78,114,134,0,
|
||||
0,0,122,89,99,97,110,39,116,32,114,101,115,111,108,118,
|
||||
101,32,112,97,99,107,97,103,101,32,102,114,111,109,32,95,
|
||||
95,115,112,101,99,95,95,32,111,114,32,95,95,112,97,99,
|
||||
107,97,103,101,95,95,44,32,102,97,108,108,105,110,103,32,
|
||||
98,97,99,107,32,111,110,32,95,95,110,97,109,101,95,95,
|
||||
32,97,110,100,32,95,95,112,97,116,104,95,95,114,140,0,
|
||||
0,0,233,3,0,0,0,114,1,0,0,0,114,131,0,0,
|
||||
0,114,121,0,0,0,114,33,0,0,0,41,6,114,42,0,
|
||||
0,0,114,123,0,0,0,114,142,0,0,0,114,143,0,0,
|
||||
0,114,176,0,0,0,114,122,0,0,0,41,3,218,7,103,
|
||||
108,111,98,97,108,115,114,88,0,0,0,114,170,0,0,0,
|
||||
114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,
|
||||
17,95,99,97,108,99,95,95,95,112,97,99,107,97,103,101,
|
||||
95,95,4,4,0,0,115,22,0,0,0,0,7,15,1,12,
|
||||
1,7,1,15,1,12,1,9,2,13,1,10,1,12,1,19,
|
||||
1,114,198,0,0,0,99,5,0,0,0,0,0,0,0,9,
|
||||
0,0,99,1,0,0,0,0,0,0,0,3,0,0,0,7,
|
||||
0,0,0,67,0,0,0,115,214,0,0,0,124,0,0,106,
|
||||
0,0,100,1,0,131,1,0,125,1,0,124,0,0,106,0,
|
||||
0,100,2,0,131,1,0,125,2,0,124,1,0,100,3,0,
|
||||
107,9,0,114,128,0,124,2,0,100,3,0,107,9,0,114,
|
||||
124,0,124,1,0,124,2,0,106,1,0,107,3,0,114,124,
|
||||
0,116,2,0,106,3,0,100,4,0,106,4,0,100,5,0,
|
||||
124,1,0,155,2,0,100,6,0,124,2,0,106,1,0,155,
|
||||
2,0,100,7,0,103,5,0,131,1,0,116,5,0,100,8,
|
||||
0,100,9,0,131,2,1,1,124,1,0,83,124,2,0,100,
|
||||
3,0,107,9,0,114,147,0,124,2,0,106,1,0,83,116,
|
||||
2,0,106,3,0,100,10,0,116,5,0,100,8,0,100,9,
|
||||
0,131,2,1,1,124,0,0,100,11,0,25,125,1,0,100,
|
||||
12,0,124,0,0,107,7,0,114,210,0,124,1,0,106,6,
|
||||
0,100,13,0,131,1,0,100,14,0,25,125,1,0,124,1,
|
||||
0,83,41,15,122,167,67,97,108,99,117,108,97,116,101,32,
|
||||
119,104,97,116,32,95,95,112,97,99,107,97,103,101,95,95,
|
||||
32,115,104,111,117,108,100,32,98,101,46,10,10,32,32,32,
|
||||
32,95,95,112,97,99,107,97,103,101,95,95,32,105,115,32,
|
||||
110,111,116,32,103,117,97,114,97,110,116,101,101,100,32,116,
|
||||
111,32,98,101,32,100,101,102,105,110,101,100,32,111,114,32,
|
||||
99,111,117,108,100,32,98,101,32,115,101,116,32,116,111,32,
|
||||
78,111,110,101,10,32,32,32,32,116,111,32,114,101,112,114,
|
||||
101,115,101,110,116,32,116,104,97,116,32,105,116,115,32,112,
|
||||
114,111,112,101,114,32,118,97,108,117,101,32,105,115,32,117,
|
||||
110,107,110,111,119,110,46,10,10,32,32,32,32,114,134,0,
|
||||
0,0,114,95,0,0,0,78,218,0,122,32,95,95,112,97,
|
||||
99,107,97,103,101,95,95,32,33,61,32,95,95,115,112,101,
|
||||
99,95,95,46,112,97,114,101,110,116,32,40,122,4,32,33,
|
||||
61,32,250,1,41,114,140,0,0,0,233,3,0,0,0,122,
|
||||
89,99,97,110,39,116,32,114,101,115,111,108,118,101,32,112,
|
||||
97,99,107,97,103,101,32,102,114,111,109,32,95,95,115,112,
|
||||
101,99,95,95,32,111,114,32,95,95,112,97,99,107,97,103,
|
||||
101,95,95,44,32,102,97,108,108,105,110,103,32,98,97,99,
|
||||
107,32,111,110,32,95,95,110,97,109,101,95,95,32,97,110,
|
||||
100,32,95,95,112,97,116,104,95,95,114,1,0,0,0,114,
|
||||
131,0,0,0,114,121,0,0,0,114,33,0,0,0,41,7,
|
||||
114,42,0,0,0,114,123,0,0,0,114,142,0,0,0,114,
|
||||
143,0,0,0,114,115,0,0,0,114,176,0,0,0,114,122,
|
||||
0,0,0,41,3,218,7,103,108,111,98,97,108,115,114,170,
|
||||
0,0,0,114,88,0,0,0,114,10,0,0,0,114,10,0,
|
||||
0,0,114,11,0,0,0,218,17,95,99,97,108,99,95,95,
|
||||
95,112,97,99,107,97,103,101,95,95,4,4,0,0,115,30,
|
||||
0,0,0,0,7,15,1,15,1,12,1,27,1,42,2,13,
|
||||
1,4,1,12,1,7,2,9,2,13,1,10,1,12,1,19,
|
||||
1,114,200,0,0,0,99,5,0,0,0,0,0,0,0,9,
|
||||
0,0,0,5,0,0,0,67,0,0,0,115,227,0,0,0,
|
||||
124,4,0,100,1,0,107,2,0,114,27,0,116,0,0,124,
|
||||
0,0,131,1,0,125,5,0,110,54,0,124,1,0,100,2,
|
||||
|
@ -1870,17 +1879,17 @@ const unsigned char _Py_M__importlib[] = {
|
|||
111,117,108,100,32,104,97,118,101,32,97,32,39,108,101,118,
|
||||
101,108,39,32,111,102,32,50,41,46,10,10,32,32,32,32,
|
||||
114,33,0,0,0,78,114,121,0,0,0,41,8,114,187,0,
|
||||
0,0,114,198,0,0,0,218,9,112,97,114,116,105,116,105,
|
||||
0,0,114,200,0,0,0,218,9,112,97,114,116,105,116,105,
|
||||
111,110,114,168,0,0,0,114,14,0,0,0,114,21,0,0,
|
||||
0,114,1,0,0,0,114,195,0,0,0,41,9,114,15,0,
|
||||
0,0,114,197,0,0,0,218,6,108,111,99,97,108,115,114,
|
||||
0,0,114,199,0,0,0,218,6,108,111,99,97,108,115,114,
|
||||
193,0,0,0,114,171,0,0,0,114,89,0,0,0,90,8,
|
||||
103,108,111,98,97,108,115,95,114,170,0,0,0,90,7,99,
|
||||
117,116,95,111,102,102,114,10,0,0,0,114,10,0,0,0,
|
||||
114,11,0,0,0,218,10,95,95,105,109,112,111,114,116,95,
|
||||
95,25,4,0,0,115,26,0,0,0,0,11,12,1,15,2,
|
||||
95,31,4,0,0,115,26,0,0,0,0,11,12,1,15,2,
|
||||
24,1,12,1,18,1,6,3,12,1,23,1,6,1,4,4,
|
||||
35,3,40,2,114,201,0,0,0,99,1,0,0,0,0,0,
|
||||
35,3,40,2,114,203,0,0,0,99,1,0,0,0,0,0,
|
||||
0,0,2,0,0,0,3,0,0,0,67,0,0,0,115,53,
|
||||
0,0,0,116,0,0,106,1,0,124,0,0,131,1,0,125,
|
||||
1,0,124,1,0,100,0,0,107,8,0,114,43,0,116,2,
|
||||
|
@ -1891,8 +1900,8 @@ const unsigned char _Py_M__importlib[] = {
|
|||
0,0,114,77,0,0,0,114,150,0,0,0,41,2,114,15,
|
||||
0,0,0,114,88,0,0,0,114,10,0,0,0,114,10,0,
|
||||
0,0,114,11,0,0,0,218,18,95,98,117,105,108,116,105,
|
||||
110,95,102,114,111,109,95,110,97,109,101,60,4,0,0,115,
|
||||
8,0,0,0,0,1,15,1,12,1,16,1,114,202,0,0,
|
||||
110,95,102,114,111,109,95,110,97,109,101,66,4,0,0,115,
|
||||
8,0,0,0,0,1,15,1,12,1,16,1,114,204,0,0,
|
||||
0,99,2,0,0,0,0,0,0,0,12,0,0,0,12,0,
|
||||
0,0,67,0,0,0,115,74,1,0,0,124,1,0,97,0,
|
||||
0,124,0,0,97,1,0,116,2,0,116,1,0,131,1,0,
|
||||
|
@ -1937,7 +1946,7 @@ const unsigned char _Py_M__importlib[] = {
|
|||
0,114,21,0,0,0,218,5,105,116,101,109,115,114,178,0,
|
||||
0,0,114,76,0,0,0,114,151,0,0,0,114,82,0,0,
|
||||
0,114,161,0,0,0,114,132,0,0,0,114,137,0,0,0,
|
||||
114,1,0,0,0,114,202,0,0,0,114,5,0,0,0,114,
|
||||
114,1,0,0,0,114,204,0,0,0,114,5,0,0,0,114,
|
||||
77,0,0,0,41,12,218,10,115,121,115,95,109,111,100,117,
|
||||
108,101,218,11,95,105,109,112,95,109,111,100,117,108,101,90,
|
||||
11,109,111,100,117,108,101,95,116,121,112,101,114,15,0,0,
|
||||
|
@ -1948,10 +1957,10 @@ const unsigned char _Py_M__importlib[] = {
|
|||
101,97,100,95,109,111,100,117,108,101,90,14,119,101,97,107,
|
||||
114,101,102,95,109,111,100,117,108,101,114,10,0,0,0,114,
|
||||
10,0,0,0,114,11,0,0,0,218,6,95,115,101,116,117,
|
||||
112,67,4,0,0,115,50,0,0,0,0,9,6,1,6,3,
|
||||
112,73,4,0,0,115,50,0,0,0,0,9,6,1,6,3,
|
||||
12,1,28,1,15,1,15,1,9,1,15,1,9,2,3,1,
|
||||
15,1,17,3,13,1,13,1,15,1,15,2,13,1,20,3,
|
||||
3,1,16,1,13,2,11,1,16,3,12,1,114,206,0,0,
|
||||
3,1,16,1,13,2,11,1,16,3,12,1,114,208,0,0,
|
||||
0,99,2,0,0,0,0,0,0,0,3,0,0,0,3,0,
|
||||
0,0,67,0,0,0,115,87,0,0,0,116,0,0,124,0,
|
||||
0,124,1,0,131,2,0,1,116,1,0,106,2,0,106,3,
|
||||
|
@ -1963,15 +1972,15 @@ const unsigned char _Py_M__importlib[] = {
|
|||
112,111,114,116,108,105,98,32,97,115,32,116,104,101,32,105,
|
||||
109,112,108,101,109,101,110,116,97,116,105,111,110,32,111,102,
|
||||
32,105,109,112,111,114,116,46,114,33,0,0,0,78,41,11,
|
||||
114,206,0,0,0,114,14,0,0,0,114,175,0,0,0,114,
|
||||
114,208,0,0,0,114,14,0,0,0,114,175,0,0,0,114,
|
||||
113,0,0,0,114,151,0,0,0,114,161,0,0,0,218,26,
|
||||
95,102,114,111,122,101,110,95,105,109,112,111,114,116,108,105,
|
||||
98,95,101,120,116,101,114,110,97,108,114,119,0,0,0,218,
|
||||
8,95,105,110,115,116,97,108,108,114,21,0,0,0,114,1,
|
||||
0,0,0,41,3,114,204,0,0,0,114,205,0,0,0,114,
|
||||
207,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
|
||||
0,0,0,114,208,0,0,0,114,4,0,0,115,12,0,0,
|
||||
0,0,2,13,2,16,1,16,3,12,1,6,1,114,208,0,
|
||||
0,0,0,41,3,114,206,0,0,0,114,207,0,0,0,114,
|
||||
209,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
|
||||
0,0,0,114,210,0,0,0,120,4,0,0,115,12,0,0,
|
||||
0,0,2,13,2,16,1,16,3,12,1,6,1,114,210,0,
|
||||
0,0,41,51,114,3,0,0,0,114,119,0,0,0,114,12,
|
||||
0,0,0,114,16,0,0,0,114,17,0,0,0,114,59,0,
|
||||
0,0,114,41,0,0,0,114,48,0,0,0,114,31,0,0,
|
||||
|
@ -1987,8 +1996,8 @@ const unsigned char _Py_M__importlib[] = {
|
|||
0,114,172,0,0,0,114,174,0,0,0,114,177,0,0,0,
|
||||
114,182,0,0,0,114,192,0,0,0,114,183,0,0,0,114,
|
||||
185,0,0,0,114,186,0,0,0,114,187,0,0,0,114,195,
|
||||
0,0,0,114,198,0,0,0,114,201,0,0,0,114,202,0,
|
||||
0,0,114,206,0,0,0,114,208,0,0,0,114,10,0,0,
|
||||
0,0,0,114,200,0,0,0,114,203,0,0,0,114,204,0,
|
||||
0,0,114,208,0,0,0,114,210,0,0,0,114,10,0,0,
|
||||
0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
|
||||
218,8,60,109,111,100,117,108,101,62,8,0,0,0,115,96,
|
||||
0,0,0,6,17,6,2,12,8,12,4,19,20,6,2,6,
|
||||
|
@ -1996,6 +2005,6 @@ const unsigned char _Py_M__importlib[] = {
|
|||
8,12,11,12,12,12,16,12,36,19,27,19,101,24,26,9,
|
||||
3,18,45,18,60,12,18,12,17,12,25,12,29,12,23,12,
|
||||
16,19,73,19,77,19,13,12,9,12,9,15,40,12,17,6,
|
||||
1,10,2,12,27,12,6,18,24,12,32,12,21,24,35,12,
|
||||
1,10,2,12,27,12,6,18,24,12,32,12,27,24,35,12,
|
||||
7,12,47,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue