]> granicus.if.org Git - python/commitdiff
Improper type for __package__ should raise TypeError, not ValueError.
authorBrett Cannon <brett@python.org>
Thu, 23 Feb 2012 23:29:12 +0000 (18:29 -0500)
committerBrett Cannon <brett@python.org>
Thu, 23 Feb 2012 23:29:12 +0000 (18:29 -0500)
Lib/importlib/_bootstrap.py
Lib/importlib/test/import_/test___package__.py

index 6382079c19b8108c70eb11245a243f9928372799..ccdea85df636cf7b91a92d510dde067dc3fd99cc 100644 (file)
@@ -926,7 +926,7 @@ def _sanity_check(name, package, level):
         raise ValueError('level must be >= 0')
     if package:
         if not isinstance(package, str):
-            raise ValueError("__package__ not set to a string")
+            raise TypeError("__package__ not set to a string")
         elif package not in sys.modules:
             msg = ("Parent module {0!r} not loaded, cannot perform relative "
                    "import")
index 5056ae59cca5a6d6fe1756c0d243f01b7e02643e..783cde17294a788b63f010d925aa3f49dd0f392b 100644 (file)
@@ -67,7 +67,7 @@ class Using__package__(unittest.TestCase):
 
     def test_bunk__package__(self):
         globals = {'__package__': 42}
-        with self.assertRaises(ValueError):
+        with self.assertRaises(TypeError):
             import_util.import_('', globals, {}, ['relimport'], 1)