Safer sys.modules delete

This commit is contained in:
Patrick Hayes 2017-02-14 16:54:32 -08:00
parent 427bf42a52
commit 58ce3a9e8c
1 changed files with 2 additions and 1 deletions

View File

@ -215,7 +215,8 @@ class AssertionRewritingHook(object):
mod.__loader__ = self mod.__loader__ = self
py.builtin.exec_(co, mod.__dict__) py.builtin.exec_(co, mod.__dict__)
except: except:
del sys.modules[name] if name in sys.modules:
del sys.modules[name]
raise raise
return sys.modules[name] return sys.modules[name]