diff options
author | Brett Cannon <brett@python.org> | 2012-02-23 23:18:48 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-02-23 23:18:48 (GMT) |
commit | 068915cc8b75720192be0e5834e7e25993fae5ff (patch) | |
tree | 424073635ab4f93bdea6db9c2381235bc428fad2 /Lib | |
parent | 5b761f1dca44e532f24be3bfb758058cb63afb55 (diff) | |
download | cpython-068915cc8b75720192be0e5834e7e25993fae5ff.zip cpython-068915cc8b75720192be0e5834e7e25993fae5ff.tar.gz cpython-068915cc8b75720192be0e5834e7e25993fae5ff.tar.bz2 |
Do a type check instead of an interface check.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index 6c4367f..6382079 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -920,12 +920,12 @@ def _find_module(name, path): 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 " |