diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-08-04 02:29:12 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-08-04 02:29:12 (GMT) |
commit | 3d3cfdb4994ed672436e3e16b66ac1b9349543db (patch) | |
tree | f19d6781141cc18952f27285aadb7b5355c54bb5 /Lib/imputil.py | |
parent | 51fa3b740f3d76a26942904e151d366699b3eba9 (diff) | |
download | cpython-3d3cfdb4994ed672436e3e16b66ac1b9349543db.zip cpython-3d3cfdb4994ed672436e3e16b66ac1b9349543db.tar.gz cpython-3d3cfdb4994ed672436e3e16b66ac1b9349543db.tar.bz2 |
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.
Diffstat (limited to 'Lib/imputil.py')
-rw-r--r-- | Lib/imputil.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/imputil.py b/Lib/imputil.py index 04111dc..e6ad7ec 100644 --- a/Lib/imputil.py +++ b/Lib/imputil.py @@ -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 |