Issue #14583: Fix importlib bug when a package's __init__.py would first import one of its modules then raise an error.

This commit is contained in:
Antoine Pitrou 2012-05-07 21:41:59 +02:00
parent 943cab2fec
commit 6efa50a384
6 changed files with 374 additions and 308 deletions

View file

@ -1082,7 +1082,7 @@ def __import__(name, globals={}, locals={}, fromlist=[], level=0):
# Return up to the first dot in 'name'. This is complicated by the fact
# that 'name' may be relative.
if level == 0:
return sys.modules[name.partition('.')[0]]
return _gcd_import(name.partition('.')[0])
elif not name:
return module
else: