Show More
@@ -236,12 +236,19 b' def superreload(module, reload=reload, old_objects={}):' | |||||
236 | # reload module |
|
236 | # reload module | |
237 | try: |
|
237 | try: | |
238 | # clear namespace first from old cruft |
|
238 | # clear namespace first from old cruft | |
|
239 | old_dict = module.__dict__.copy() | |||
239 | old_name = module.__name__ |
|
240 | old_name = module.__name__ | |
240 | module.__dict__.clear() |
|
241 | module.__dict__.clear() | |
241 | module.__dict__['__name__'] = old_name |
|
242 | module.__dict__['__name__'] = old_name | |
242 | except (TypeError, AttributeError, KeyError): |
|
243 | except (TypeError, AttributeError, KeyError): | |
243 | pass |
|
244 | pass | |
244 | module = reload(module) |
|
245 | ||
|
246 | try: | |||
|
247 | module = reload(module) | |||
|
248 | except: | |||
|
249 | # restore module dictionary on failed reload | |||
|
250 | module.__dict__.update(old_dict) | |||
|
251 | raise | |||
245 |
|
252 | |||
246 | # iterate over all objects and update functions & classes |
|
253 | # iterate over all objects and update functions & classes | |
247 | for name, new_obj in module.__dict__.items(): |
|
254 | for name, new_obj in module.__dict__.items(): |
General Comments 0
You need to be logged in to leave comments.
Login now