From 1bc3af5ff76eb4b5b48468e88b0f67aff9f0265b 2013-10-29 16:15:56 From: Thomas Kluyver Date: 2013-10-29 16:15:56 Subject: [PATCH] Fix autoreload tests --- diff --git a/IPython/extensions/autoreload.py b/IPython/extensions/autoreload.py index 35a7bd0..4cc3673 100644 --- a/IPython/extensions/autoreload.py +++ b/IPython/extensions/autoreload.py @@ -186,9 +186,9 @@ class ModuleReloader(object): return if check_all or self.check_all: - modules = sys.modules.keys() + modules = list(sys.modules.keys()) else: - modules = self.modules.keys() + modules = list(self.modules.keys()) for modname in modules: m = sys.modules.get(modname, None) @@ -258,7 +258,7 @@ def update_function(old, new): def update_class(old, new): """Replace stuff in the __dict__ of a class, and upgrade method code objects""" - for key in old.__dict__.keys(): + for key in list(old.__dict__.keys()): old_obj = getattr(old, key) try: @@ -339,7 +339,7 @@ def superreload(module, reload=reload, old_objects={}): """ # collect old objects in the module - for name, obj in module.__dict__.items(): + for name, obj in list(module.__dict__.items()): if not hasattr(obj, '__module__') or obj.__module__ != module.__name__: continue key = (module.__name__, name) @@ -370,7 +370,7 @@ def superreload(module, reload=reload, old_objects={}): raise # iterate over all objects and update functions & classes - for name, new_obj in module.__dict__.items(): + for name, new_obj in list(module.__dict__.items()): key = (module.__name__, name) if key not in old_objects: continue @@ -473,9 +473,8 @@ class AutoreloadMagics(Magics): """ modname = parameter_s if not modname: - to_reload = self._reloader.modules.keys() - to_reload.sort() - to_skip = self._reloader.skip_modules.keys() + to_reload = sorted(self._reloader.modules.keys()) + to_skip = sorted(self._reloader.skip_modules.keys()) to_skip.sort() if stream is None: stream = sys.stdout