Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUG: extensions/autoreload: don't clobber module dictionary if reload…

… fails
  • Loading branch information...
commit cdc9b79494ed7e7be5aab7459144a9f9c09385d9 1 parent ca85fb0
@pv authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 IPython/extensions/autoreload.py
View
9 IPython/extensions/autoreload.py
@@ -236,12 +236,19 @@ def superreload(module, reload=reload, old_objects={}):
# reload module
try:
# clear namespace first from old cruft
+ old_dict = module.__dict__.copy()
old_name = module.__name__
module.__dict__.clear()
module.__dict__['__name__'] = old_name
except (TypeError, AttributeError, KeyError):
pass
- module = reload(module)
+
+ try:
+ module = reload(module)
+ except:
+ # restore module dictionary on failed reload
+ module.__dict__.update(old_dict)
+ raise
# iterate over all objects and update functions & classes
for name, new_obj in module.__dict__.items():
Please sign in to comment.
Something went wrong with that request. Please try again.