[Python-checkins] cpython: Do a type check instead of an interface check.

brett.cannon python-checkins at python.org
Fri Feb 24 00:30:16 CET 2012


http://hg.python.org/cpython/rev/909935a236e3
changeset: 75228:909935a236e3
parent: 75194:6f578f73d14a
user: Brett Cannon <brett at python.org>
date: Thu Feb 23 18:18:48 2012 -0500
summary:
 Do a type check instead of an interface check.
files:
 Lib/importlib/_bootstrap.py | 4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -920,12 +920,12 @@
 
 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'):
+ if not isinstance(package, str):
 raise ValueError("__package__ not set to a string")
 elif package not in sys.modules:
 msg = ("Parent module {0!r} not loaded, cannot perform relative "
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /