summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorNgalim Siregar <ngalim.siregar@gmail.com>2019-08-03 05:46:02 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-08-03 05:46:02 (GMT)
commitc5fa44944ee0a31a12b9a70776c7cb56c4dc39a2 (patch)
treea0cbe2dbb223339419432483b9c893654f06100c /Python
parent8e568ef266a2805f9a6042003723d9c050830461 (diff)
downloadcpython-c5fa44944ee0a31a12b9a70776c7cb56c4dc39a2.zip
cpython-c5fa44944ee0a31a12b9a70776c7cb56c4dc39a2.tar.gz
cpython-c5fa44944ee0a31a12b9a70776c7cb56c4dc39a2.tar.bz2
bpo-37444: Update differing exception between builtins and importlib (GH-14869)
Imports now raise `TypeError` instead of `ValueError` for relative import failures. This makes things consistent between `builtins.__import__` and `importlib.__import__` as well as using a more natural import for the failure. https://bugs.python.org/issue37444 Automerge-Triggered-By: @brettcannon
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c2
-rw-r--r--Python/importlib.h192
2 files changed, 97 insertions, 97 deletions
diff --git a/Python/import.c b/Python/import.c
index 9f5ec28..41c2f34 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1671,7 +1671,7 @@ resolve_name(PyThreadState *tstate, PyObject *name, PyObject *globals, int level
goto error;
}
else if (last_dot == -1) {
- _PyErr_SetString(tstate, PyExc_ValueError,
+ _PyErr_SetString(tstate, PyExc_ImportError,
"attempted relative import beyond top-level "
"package");
goto error;
diff --git a/Python/importlib.h b/Python/importlib.h
index a285a31..a6952af 100644
--- a/Python/importlib.h
+++ b/Python/importlib.h
@@ -1351,89 +1351,89 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
112,111,114,116,32,98,101,121,111,110,100,32,116,111,112,45,
108,101,118,101,108,32,112,97,99,107,97,103,101,114,22,0,
0,0,250,5,123,125,46,123,125,41,4,218,6,114,115,112,
- 108,105,116,218,3,108,101,110,218,10,86,97,108,117,101,69,
- 114,114,111,114,114,45,0,0,0,41,5,114,17,0,0,0,
- 218,7,112,97,99,107,97,103,101,218,5,108,101,118,101,108,
- 90,4,98,105,116,115,90,4,98,97,115,101,114,10,0,0,
- 0,114,10,0,0,0,114,11,0,0,0,218,13,95,114,101,
- 115,111,108,118,101,95,110,97,109,101,104,3,0,0,115,10,
- 0,0,0,0,2,16,1,12,1,8,1,8,1,114,188,0,
- 0,0,99,3,0,0,0,0,0,0,0,0,0,0,0,4,
- 0,0,0,4,0,0,0,67,0,0,0,115,34,0,0,0,
- 124,0,160,0,124,1,124,2,161,2,125,3,124,3,100,0,
- 107,8,114,24,100,0,83,0,116,1,124,1,124,3,131,2,
- 83,0,114,13,0,0,0,41,2,114,167,0,0,0,114,91,
- 0,0,0,41,4,218,6,102,105,110,100,101,114,114,17,0,
- 0,0,114,164,0,0,0,114,109,0,0,0,114,10,0,0,
- 0,114,10,0,0,0,114,11,0,0,0,218,17,95,102,105,
- 110,100,95,115,112,101,99,95,108,101,103,97,99,121,113,3,
- 0,0,115,8,0,0,0,0,3,12,1,8,1,4,1,114,
- 190,0,0,0,99,3,0,0,0,0,0,0,0,0,0,0,
- 0,10,0,0,0,10,0,0,0,67,0,0,0,115,12,1,
- 0,0,116,0,106,1,125,3,124,3,100,1,107,8,114,22,
- 116,2,100,2,131,1,130,1,124,3,115,38,116,3,160,4,
- 100,3,116,5,161,2,1,0,124,0,116,0,106,6,107,6,
- 125,4,124,3,68,0,93,210,125,5,116,7,131,0,143,84,
- 1,0,122,10,124,5,106,8,125,6,87,0,110,54,4,0,
- 116,9,107,10,114,128,1,0,1,0,1,0,116,10,124,5,
- 124,0,124,1,131,3,125,7,124,7,100,1,107,8,114,124,
- 89,0,87,0,53,0,81,0,82,0,163,0,113,52,89,0,
- 110,14,88,0,124,6,124,0,124,1,124,2,131,3,125,7,
- 87,0,53,0,81,0,82,0,88,0,124,7,100,1,107,9,
- 114,52,124,4,144,0,115,254,124,0,116,0,106,6,107,6,
- 144,0,114,254,116,0,106,6,124,0,25,0,125,8,122,10,
- 124,8,106,11,125,9,87,0,110,28,4,0,116,9,107,10,
- 114,226,1,0,1,0,1,0,124,7,6,0,89,0,2,0,
- 1,0,83,0,88,0,124,9,100,1,107,8,114,244,124,7,
- 2,0,1,0,83,0,124,9,2,0,1,0,83,0,113,52,
- 124,7,2,0,1,0,83,0,113,52,100,1,83,0,41,4,
- 122,21,70,105,110,100,32,97,32,109,111,100,117,108,101,39,
- 115,32,115,112,101,99,46,78,122,53,115,121,115,46,109,101,
- 116,97,95,112,97,116,104,32,105,115,32,78,111,110,101,44,
- 32,80,121,116,104,111,110,32,105,115,32,108,105,107,101,108,
- 121,32,115,104,117,116,116,105,110,103,32,100,111,119,110,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,12,114,15,0,0,0,218,9,
- 109,101,116,97,95,112,97,116,104,114,79,0,0,0,218,9,
- 95,119,97,114,110,105,110,103,115,218,4,119,97,114,110,218,
- 13,73,109,112,111,114,116,87,97,114,110,105,110,103,114,92,
- 0,0,0,114,178,0,0,0,114,166,0,0,0,114,106,0,
- 0,0,114,190,0,0,0,114,105,0,0,0,41,10,114,17,
- 0,0,0,114,164,0,0,0,114,165,0,0,0,114,191,0,
- 0,0,90,9,105,115,95,114,101,108,111,97,100,114,189,0,
- 0,0,114,166,0,0,0,114,95,0,0,0,114,96,0,0,
- 0,114,105,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,218,10,95,102,105,110,100,95,115,112,101,
- 99,122,3,0,0,115,54,0,0,0,0,2,6,1,8,2,
- 8,3,4,1,12,5,10,1,8,1,8,1,2,1,10,1,
- 14,1,12,1,8,1,20,2,22,1,8,2,18,1,10,1,
- 2,1,10,1,14,4,14,2,8,1,8,2,10,2,10,2,
- 114,195,0,0,0,99,3,0,0,0,0,0,0,0,0,0,
- 0,0,3,0,0,0,5,0,0,0,67,0,0,0,115,108,
- 0,0,0,116,0,124,0,116,1,131,2,115,28,116,2,100,
- 1,160,3,116,4,124,0,131,1,161,1,131,1,130,1,124,
- 2,100,2,107,0,114,44,116,5,100,3,131,1,130,1,124,
- 2,100,2,107,4,114,84,116,0,124,1,116,1,131,2,115,
- 72,116,2,100,4,131,1,130,1,110,12,124,1,115,84,116,
- 6,100,5,131,1,130,1,124,0,115,104,124,2,100,2,107,
- 2,114,104,116,5,100,6,131,1,130,1,100,7,83,0,41,
- 8,122,28,86,101,114,105,102,121,32,97,114,103,117,109,101,
- 110,116,115,32,97,114,101,32,34,115,97,110,101,34,46,122,
- 31,109,111,100,117,108,101,32,110,97,109,101,32,109,117,115,
- 116,32,98,101,32,115,116,114,44,32,110,111,116,32,123,125,
- 114,22,0,0,0,122,18,108,101,118,101,108,32,109,117,115,
- 116,32,98,101,32,62,61,32,48,122,31,95,95,112,97,99,
- 107,97,103,101,95,95,32,110,111,116,32,115,101,116,32,116,
- 111,32,97,32,115,116,114,105,110,103,122,54,97,116,116,101,
- 109,112,116,101,100,32,114,101,108,97,116,105,118,101,32,105,
- 109,112,111,114,116,32,119,105,116,104,32,110,111,32,107,110,
- 111,119,110,32,112,97,114,101,110,116,32,112,97,99,107,97,
- 103,101,122,17,69,109,112,116,121,32,109,111,100,117,108,101,
- 32,110,97,109,101,78,41,7,218,10,105,115,105,110,115,116,
- 97,110,99,101,218,3,115,116,114,218,9,84,121,112,101,69,
- 114,114,111,114,114,45,0,0,0,114,14,0,0,0,114,185,
- 0,0,0,114,79,0,0,0,169,3,114,17,0,0,0,114,
- 186,0,0,0,114,187,0,0,0,114,10,0,0,0,114,10,
+ 108,105,116,218,3,108,101,110,114,79,0,0,0,114,45,0,
+ 0,0,41,5,114,17,0,0,0,218,7,112,97,99,107,97,
+ 103,101,218,5,108,101,118,101,108,90,4,98,105,116,115,90,
+ 4,98,97,115,101,114,10,0,0,0,114,10,0,0,0,114,
+ 11,0,0,0,218,13,95,114,101,115,111,108,118,101,95,110,
+ 97,109,101,104,3,0,0,115,10,0,0,0,0,2,16,1,
+ 12,1,8,1,8,1,114,187,0,0,0,99,3,0,0,0,
+ 0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,
+ 67,0,0,0,115,34,0,0,0,124,0,160,0,124,1,124,
+ 2,161,2,125,3,124,3,100,0,107,8,114,24,100,0,83,
+ 0,116,1,124,1,124,3,131,2,83,0,114,13,0,0,0,
+ 41,2,114,167,0,0,0,114,91,0,0,0,41,4,218,6,
+ 102,105,110,100,101,114,114,17,0,0,0,114,164,0,0,0,
+ 114,109,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
+ 11,0,0,0,218,17,95,102,105,110,100,95,115,112,101,99,
+ 95,108,101,103,97,99,121,113,3,0,0,115,8,0,0,0,
+ 0,3,12,1,8,1,4,1,114,189,0,0,0,99,3,0,
+ 0,0,0,0,0,0,0,0,0,0,10,0,0,0,10,0,
+ 0,0,67,0,0,0,115,12,1,0,0,116,0,106,1,125,
+ 3,124,3,100,1,107,8,114,22,116,2,100,2,131,1,130,
+ 1,124,3,115,38,116,3,160,4,100,3,116,5,161,2,1,
+ 0,124,0,116,0,106,6,107,6,125,4,124,3,68,0,93,
+ 210,125,5,116,7,131,0,143,84,1,0,122,10,124,5,106,
+ 8,125,6,87,0,110,54,4,0,116,9,107,10,114,128,1,
+ 0,1,0,1,0,116,10,124,5,124,0,124,1,131,3,125,
+ 7,124,7,100,1,107,8,114,124,89,0,87,0,53,0,81,
+ 0,82,0,163,0,113,52,89,0,110,14,88,0,124,6,124,
+ 0,124,1,124,2,131,3,125,7,87,0,53,0,81,0,82,
+ 0,88,0,124,7,100,1,107,9,114,52,124,4,144,0,115,
+ 254,124,0,116,0,106,6,107,6,144,0,114,254,116,0,106,
+ 6,124,0,25,0,125,8,122,10,124,8,106,11,125,9,87,
+ 0,110,28,4,0,116,9,107,10,114,226,1,0,1,0,1,
+ 0,124,7,6,0,89,0,2,0,1,0,83,0,88,0,124,
+ 9,100,1,107,8,114,244,124,7,2,0,1,0,83,0,124,
+ 9,2,0,1,0,83,0,113,52,124,7,2,0,1,0,83,
+ 0,113,52,100,1,83,0,41,4,122,21,70,105,110,100,32,
+ 97,32,109,111,100,117,108,101,39,115,32,115,112,101,99,46,
+ 78,122,53,115,121,115,46,109,101,116,97,95,112,97,116,104,
+ 32,105,115,32,78,111,110,101,44,32,80,121,116,104,111,110,
+ 32,105,115,32,108,105,107,101,108,121,32,115,104,117,116,116,
+ 105,110,103,32,100,111,119,110,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,12,114,15,0,0,0,218,9,109,101,116,97,95,112,97,
+ 116,104,114,79,0,0,0,218,9,95,119,97,114,110,105,110,
+ 103,115,218,4,119,97,114,110,218,13,73,109,112,111,114,116,
+ 87,97,114,110,105,110,103,114,92,0,0,0,114,178,0,0,
+ 0,114,166,0,0,0,114,106,0,0,0,114,189,0,0,0,
+ 114,105,0,0,0,41,10,114,17,0,0,0,114,164,0,0,
+ 0,114,165,0,0,0,114,190,0,0,0,90,9,105,115,95,
+ 114,101,108,111,97,100,114,188,0,0,0,114,166,0,0,0,
+ 114,95,0,0,0,114,96,0,0,0,114,105,0,0,0,114,
+ 10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,10,
+ 95,102,105,110,100,95,115,112,101,99,122,3,0,0,115,54,
+ 0,0,0,0,2,6,1,8,2,8,3,4,1,12,5,10,
+ 1,8,1,8,1,2,1,10,1,14,1,12,1,8,1,20,
+ 2,22,1,8,2,18,1,10,1,2,1,10,1,14,4,14,
+ 2,8,1,8,2,10,2,10,2,114,194,0,0,0,99,3,
+ 0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,5,
+ 0,0,0,67,0,0,0,115,108,0,0,0,116,0,124,0,
+ 116,1,131,2,115,28,116,2,100,1,160,3,116,4,124,0,
+ 131,1,161,1,131,1,130,1,124,2,100,2,107,0,114,44,
+ 116,5,100,3,131,1,130,1,124,2,100,2,107,4,114,84,
+ 116,0,124,1,116,1,131,2,115,72,116,2,100,4,131,1,
+ 130,1,110,12,124,1,115,84,116,6,100,5,131,1,130,1,
+ 124,0,115,104,124,2,100,2,107,2,114,104,116,5,100,6,
+ 131,1,130,1,100,7,83,0,41,8,122,28,86,101,114,105,
+ 102,121,32,97,114,103,117,109,101,110,116,115,32,97,114,101,
+ 32,34,115,97,110,101,34,46,122,31,109,111,100,117,108,101,
+ 32,110,97,109,101,32,109,117,115,116,32,98,101,32,115,116,
+ 114,44,32,110,111,116,32,123,125,114,22,0,0,0,122,18,
+ 108,101,118,101,108,32,109,117,115,116,32,98,101,32,62,61,
+ 32,48,122,31,95,95,112,97,99,107,97,103,101,95,95,32,
+ 110,111,116,32,115,101,116,32,116,111,32,97,32,115,116,114,
+ 105,110,103,122,54,97,116,116,101,109,112,116,101,100,32,114,
+ 101,108,97,116,105,118,101,32,105,109,112,111,114,116,32,119,
+ 105,116,104,32,110,111,32,107,110,111,119,110,32,112,97,114,
+ 101,110,116,32,112,97,99,107,97,103,101,122,17,69,109,112,
+ 116,121,32,109,111,100,117,108,101,32,110,97,109,101,78,41,
+ 7,218,10,105,115,105,110,115,116,97,110,99,101,218,3,115,
+ 116,114,218,9,84,121,112,101,69,114,114,111,114,114,45,0,
+ 0,0,114,14,0,0,0,218,10,86,97,108,117,101,69,114,
+ 114,111,114,114,79,0,0,0,169,3,114,17,0,0,0,114,
+ 185,0,0,0,114,186,0,0,0,114,10,0,0,0,114,10,
0,0,0,114,11,0,0,0,218,13,95,115,97,110,105,116,
121,95,99,104,101,99,107,169,3,0,0,115,22,0,0,0,
0,2,10,1,18,1,8,1,8,1,8,1,10,1,10,1,
@@ -1462,7 +1462,7 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
0,0,0,114,141,0,0,0,114,106,0,0,0,218,8,95,
69,82,82,95,77,83,71,114,45,0,0,0,218,19,77,111,
100,117,108,101,78,111,116,70,111,117,110,100,69,114,114,111,
- 114,114,195,0,0,0,114,159,0,0,0,114,5,0,0,0,
+ 114,114,194,0,0,0,114,159,0,0,0,114,5,0,0,0,
41,8,114,17,0,0,0,218,7,105,109,112,111,114,116,95,
114,164,0,0,0,114,130,0,0,0,90,13,112,97,114,101,
110,116,95,109,111,100,117,108,101,114,157,0,0,0,114,95,
@@ -1520,7 +1520,7 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
97,103,101,95,95,32,105,102,10,32,32,32,32,116,104,101,
32,108,111,97,100,101,114,32,100,105,100,32,110,111,116,46,
10,10,32,32,32,32,114,22,0,0,0,41,4,114,200,0,
- 0,0,114,188,0,0,0,114,207,0,0,0,218,11,95,103,
+ 0,0,114,187,0,0,0,114,207,0,0,0,218,11,95,103,
99,100,95,105,109,112,111,114,116,114,199,0,0,0,114,10,
0,0,0,114,10,0,0,0,114,11,0,0,0,114,208,0,
0,0,234,3,0,0,115,8,0,0,0,0,9,12,1,8,
@@ -1561,8 +1561,8 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
122,8,73,116,101,109,32,105,110,32,122,18,32,109,117,115,
116,32,98,101,32,115,116,114,44,32,110,111,116,32,250,1,
42,218,7,95,95,97,108,108,95,95,84,114,209,0,0,0,
- 114,182,0,0,0,78,41,16,114,196,0,0,0,114,197,0,
- 0,0,114,1,0,0,0,114,198,0,0,0,114,14,0,0,
+ 114,182,0,0,0,78,41,16,114,195,0,0,0,114,196,0,
+ 0,0,114,1,0,0,0,114,197,0,0,0,114,14,0,0,
0,114,4,0,0,0,218,16,95,104,97,110,100,108,101,95,
102,114,111,109,108,105,115,116,114,212,0,0,0,114,45,0,
0,0,114,67,0,0,0,114,203,0,0,0,114,17,0,0,
@@ -1609,9 +1609,9 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
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,141,0,0,
0,114,128,0,0,0,114,22,0,0,0,41,6,114,34,0,
- 0,0,114,130,0,0,0,114,192,0,0,0,114,193,0,0,
- 0,114,194,0,0,0,114,129,0,0,0,41,3,218,7,103,
- 108,111,98,97,108,115,114,186,0,0,0,114,95,0,0,0,
+ 0,0,114,130,0,0,0,114,191,0,0,0,114,192,0,0,
+ 0,114,193,0,0,0,114,129,0,0,0,41,3,218,7,103,
+ 108,111,98,97,108,115,114,185,0,0,0,114,95,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,30,4,0,0,115,38,0,0,0,0,7,10,1,10,
@@ -1666,8 +1666,8 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
111,110,114,184,0,0,0,114,15,0,0,0,114,92,0,0,
0,114,1,0,0,0,114,4,0,0,0,114,213,0,0,0,
41,9,114,17,0,0,0,114,218,0,0,0,218,6,108,111,
- 99,97,108,115,114,214,0,0,0,114,187,0,0,0,114,96,
- 0,0,0,90,8,103,108,111,98,97,108,115,95,114,186,0,
+ 99,97,108,115,114,214,0,0,0,114,186,0,0,0,114,96,
+ 0,0,0,90,8,103,108,111,98,97,108,115,95,114,185,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,57,4,0,0,115,30,0,0,0,0,
@@ -1713,10 +1713,10 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
101,32,116,119,111,32,109,111,100,117,108,101,115,32,109,117,
115,116,32,98,101,32,101,120,112,108,105,99,105,116,108,121,
32,112,97,115,115,101,100,32,105,110,46,10,10,32,32,32,
- 32,41,3,114,23,0,0,0,114,192,0,0,0,114,64,0,
+ 32,41,3,114,23,0,0,0,114,191,0,0,0,114,64,0,
0,0,78,41,15,114,57,0,0,0,114,15,0,0,0,114,
14,0,0,0,114,92,0,0,0,218,5,105,116,101,109,115,
- 114,196,0,0,0,114,78,0,0,0,114,160,0,0,0,114,
+ 114,195,0,0,0,114,78,0,0,0,114,160,0,0,0,114,
88,0,0,0,114,173,0,0,0,114,142,0,0,0,114,148,
0,0,0,114,1,0,0,0,114,223,0,0,0,114,5,0,
0,0,41,10,218,10,115,121,115,95,109,111,100,117,108,101,
@@ -1738,7 +1738,7 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
108,32,105,109,112,111,114,116,101,114,115,32,102,111,114,32,
98,117,105,108,116,105,110,32,97,110,100,32,102,114,111,122,
101,110,32,109,111,100,117,108,101,115,78,41,6,114,227,0,
- 0,0,114,15,0,0,0,114,191,0,0,0,114,120,0,0,
+ 0,0,114,15,0,0,0,114,190,0,0,0,114,120,0,0,
0,114,160,0,0,0,114,173,0,0,0,41,2,114,225,0,
0,0,114,226,0,0,0,114,10,0,0,0,114,10,0,0,
0,114,11,0,0,0,218,8,95,105,110,115,116,97,108,108,
@@ -1771,7 +1771,7 @@ const unsigned char _Py_M__importlib_bootstrap[] = {
114,148,0,0,0,114,152,0,0,0,114,107,0,0,0,114,
93,0,0,0,114,158,0,0,0,114,159,0,0,0,114,94,
0,0,0,114,160,0,0,0,114,173,0,0,0,114,178,0,
- 0,0,114,188,0,0,0,114,190,0,0,0,114,195,0,0,
+ 0,0,114,187,0,0,0,114,189,0,0,0,114,194,0,0,
0,114,200,0,0,0,90,15,95,69,82,82,95,77,83,71,
95,80,82,69,70,73,88,114,202,0,0,0,114,205,0,0,
0,218,6,111,98,106,101,99,116,114,206,0,0,0,114,207,