mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
ihooks FancyModuleLoader.load_module()
imputils Importer._process_result(): remove name from modules dict if exec fails. This is what all the builtin importers do now, new in 2.4.
This commit is contained in:
parent
51fa3b740f
commit
3d3cfdb499
2 changed files with 13 additions and 2 deletions
|
@ -297,7 +297,12 @@ class Importer:
|
|||
|
||||
# execute the code within the module's namespace
|
||||
if not is_module:
|
||||
exec code in module.__dict__
|
||||
try:
|
||||
exec code in module.__dict__
|
||||
except:
|
||||
if fqname in sys.modules:
|
||||
del sys.modules[fqname]
|
||||
raise
|
||||
|
||||
# fetch from sys.modules instead of returning module directly.
|
||||
# also make module's __name__ agree with fqname, in case
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue