From c5fa44944ee0a31a12b9a70776c7cb56c4dc39a2 Mon Sep 17 00:00:00 2001 From: Ngalim Siregar Date: Sat, 3 Aug 2019 12:46:02 +0700 Subject: 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 --- Python/import.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/import.c') diff --git a/Python/import.c b/Python/import.c index 9f5ec284ae..41c2f34f12 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; -- cgit v1.2.1