merge
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 6c4367f..ccdea85 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -920,13 +920,13 @@
 
 def _sanity_check(name, package, level):
     """Verify arguments are "sane"."""
-    if not hasattr(name, 'rpartition'):
+    if not isinstance(name, str):
         raise TypeError("module name must be str, not {}".format(type(name)))
     if level < 0:
         raise ValueError('level must be >= 0')
     if package:
-        if not hasattr(package, 'rindex'):
-            raise ValueError("__package__ not set to a string")
+        if not isinstance(package, str):
+            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")
diff --git a/Lib/importlib/test/import_/test___package__.py b/Lib/importlib/test/import_/test___package__.py
index 5056ae5..783cde1 100644
--- a/Lib/importlib/test/import_/test___package__.py
+++ b/Lib/importlib/test/import_/test___package__.py
@@ -67,7 +67,7 @@
 
     def test_bunk__package__(self):
         globals = {'__package__': 42}
-        with self.assertRaises(ValueError):
+        with self.assertRaises(TypeError):
             import_util.import_('', globals, {}, ['relimport'], 1)