diff options
author | Patrick Hayes <pfhayes@gmail.com> | 2017-02-14 16:54:32 -0800 |
---|---|---|
committer | Patrick Hayes <pfhayes@gmail.com> | 2017-02-14 16:54:32 -0800 |
commit | 58ce3a9e8c48fe557bfdc644a96df234936247e1 (patch) | |
tree | ef423e7fd1c9075d776541d2ab005a50418c0b0a /_pytest/assertion | |
parent | 427bf42a52b524e846bcd2320a511832ac9233f3 (diff) | |
download | pytest-58ce3a9e8c48fe557bfdc644a96df234936247e1.tar.gz |
Safer sys.modules delete
Diffstat (limited to '_pytest/assertion')
-rw-r--r-- | _pytest/assertion/rewrite.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py index abf5b491f..7408c4746 100644 --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -215,7 +215,8 @@ class AssertionRewritingHook(object): mod.__loader__ = self py.builtin.exec_(co, mod.__dict__) except: - del sys.modules[name] + if name in sys.modules: + del sys.modules[name] raise return sys.modules[name] |