Kaydet (Commit) 068915cc authored tarafından Brett Cannon's avatar Brett Cannon

Do a type check instead of an interface check.

üst 5b761f1d
......@@ -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 "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment