diff options
author | Ngalim Siregar <ngalim.siregar@gmail.com> | 2019-08-03 12:46:02 +0700 |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-08-02 22:46:02 -0700 |
commit | c5fa44944ee0a31a12b9a70776c7cb56c4dc39a2 (patch) | |
tree | a0cbe2dbb223339419432483b9c893654f06100c /Lib/importlib/util.py | |
parent | 8e568ef266a2805f9a6042003723d9c050830461 (diff) | |
download | cpython-git-c5fa44944ee0a31a12b9a70776c7cb56c4dc39a2.tar.gz |
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 'Lib/importlib/util.py')
-rw-r--r-- | Lib/importlib/util.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py index 201e0f4cb8..269a6fa930 100644 --- a/Lib/importlib/util.py +++ b/Lib/importlib/util.py @@ -29,8 +29,8 @@ def resolve_name(name, package): if not name.startswith('.'): return name elif not package: - raise ValueError(f'no package specified for {repr(name)} ' - '(required for relative module names)') + raise ImportError(f'no package specified for {repr(name)} ' + '(required for relative module names)') level = 0 for character in name: if character != '.': |