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

@ -124,7 +124,11 @@ class mock_modules:
else:
sys.modules[fullname] = self.modules[fullname]
if fullname in self.module_code:
self.module_code[fullname]()
try:
self.module_code[fullname]()
except Exception:
del sys.modules[fullname]
raise
return self.modules[fullname]
def __enter__(self):