mirror of
https://github.com/python/cpython.git
synced 2025-09-25 01:43:11 +00:00
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:
parent
943cab2fec
commit
6efa50a384
6 changed files with 374 additions and 308 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue