summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/__init__.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-08-12 17:29:11 (GMT)
committerBrett Cannon <brett@python.org>2013-08-12 17:29:11 (GMT)
commite1f159722e9767ccd28d13fc4cd6a18f7adfcc47 (patch)
treecbf79e7f1a27e5c4200355ddf1288c9dd60c3b4d /Lib/importlib/__init__.py
parent388a3921cf21a5ff99b1f80ebc5ada3db63225b8 (diff)
downloadcpython-e1f159722e9767ccd28d13fc4cd6a18f7adfcc47.zip
cpython-e1f159722e9767ccd28d13fc4cd6a18f7adfcc47.tar.gz
cpython-e1f159722e9767ccd28d13fc4cd6a18f7adfcc47.tar.bz2
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.
Diffstat (limited to 'Lib/importlib/__init__.py')
-rw-r--r--Lib/importlib/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py
index aab54a7..6732977 100644
--- a/Lib/importlib/__init__.py
+++ b/Lib/importlib/__init__.py
@@ -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