Commit c6fbf47b authored by Benjamin Peterson's avatar Benjamin Peterson

merge heads

parents 6eaaeff0 625cd23d
...@@ -890,17 +890,11 @@ class _ImportLockContext: ...@@ -890,17 +890,11 @@ class _ImportLockContext:
def _resolve_name(name, package, level): def _resolve_name(name, package, level):
"""Resolve a relative module name to an absolute one.""" """Resolve a relative module name to an absolute one."""
dot = len(package) bits = package.rsplit('.', level-1)
for x in range(level, 1, -1): if len(bits) < level:
try: raise ValueError('attempted relative import beyond top-level package')
dot = package.rindex('.', 0, dot) base = bits[0]
except ValueError: return '{0}.{1}'.format(base, name) if name else base
raise ValueError("attempted relative import beyond "
"top-level package")
if name:
return "{0}.{1}".format(package[:dot], name)
else:
return package[:dot]
def _find_module(name, path): def _find_module(name, path):
......
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