mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Closes issue #18598: Have the exception message for
importlib.import_module() include the name of the module when the 'package' argument is missing but needed.
This commit is contained in:
parent
388a3921cf
commit
e1f159722e
2 changed files with 6 additions and 1 deletions
|
@ -85,7 +85,9 @@ def import_module(name, package=None):
|
|||
level = 0
|
||||
if name.startswith('.'):
|
||||
if not package:
|
||||
raise TypeError("relative imports require the 'package' argument")
|
||||
msg = ("the 'package' argument is required to perform a relative "
|
||||
"import for {!r}")
|
||||
raise TypeError(msg.format(name))
|
||||
for character in name:
|
||||
if character != '.':
|
||||
break
|
||||
|
|
|
@ -24,6 +24,9 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #18598: Tweak exception message for importlib.import_module() to
|
||||
include the module name when a key argument is missing.
|
||||
|
||||
- Issue #18676: Change 'positive' to 'non-negative' in queue.py put and get
|
||||
docstrings and ValueError messages. Patch by Zhongyue Luo
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue