]> granicus.if.org Git - python/commitdiff
Closes issue #18598: Have the exception message for
authorBrett Cannon <brett@python.org>
Mon, 12 Aug 2013 17:29:11 +0000 (13:29 -0400)
committerBrett Cannon <brett@python.org>
Mon, 12 Aug 2013 17:29:11 +0000 (13:29 -0400)
importlib.import_module() include the name of the module when the
'package' argument is missing but needed.

Lib/importlib/__init__.py
Misc/NEWS

index aab54a7f1877dfe045af0837dd7372b047a2f673..6732977a2bbd36dc1272f6eeeb37c3b9e5e565c4 100644 (file)
@@ -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
index a9f2b8b3309cf8c82601e8e32d66e165becc14dd..15bee70749e0b09a407972932da5bade7836b017 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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