diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-05-07 19:41:59 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-05-07 19:41:59 (GMT) |
commit | 6efa50a384f61155cd5315cd32f0f8775fe124c5 (patch) | |
tree | 2cc831c060e953beb452ec4b33e199e2c06f25d9 /Lib/importlib/test/util.py | |
parent | 943cab2fec8e7fb3232e72d9f1ca6535674e746a (diff) | |
download | cpython-6efa50a384f61155cd5315cd32f0f8775fe124c5.zip cpython-6efa50a384f61155cd5315cd32f0f8775fe124c5.tar.gz cpython-6efa50a384f61155cd5315cd32f0f8775fe124c5.tar.bz2 |
Issue #14583: Fix importlib bug when a package's __init__.py would first import one of its modules then raise an error.
Diffstat (limited to 'Lib/importlib/test/util.py')
-rw-r--r-- | Lib/importlib/test/util.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/importlib/test/util.py b/Lib/importlib/test/util.py index 7ba7a97..ef32f7d 100644 --- a/Lib/importlib/test/util.py +++ b/Lib/importlib/test/util.py @@ -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): |