From 8deecedc6d4b4c7cb914ad0220c3db0ef33dc8d8 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Thu, 13 Apr 2000 14:52:27 +0000 Subject: [PATCH] Thomas Heller : ihooks.ModuleLoader does not implement reload(mod) correctly: If mod has already been loaded by ModuleLoader, it has been returned from a cache. Added an additional parameter to import_it() to force reloading. --- Lib/ihooks.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Lib/ihooks.py b/Lib/ihooks.py index 5c9adfe82be..3f1984c7b9a 100644 --- a/Lib/ihooks.py +++ b/Lib/ihooks.py @@ -467,13 +467,14 @@ def ensure_fromlist(self, m, fromlist, recursive=0): if not submod: raise ImportError, "No module named " + subname - def import_it(self, partname, fqname, parent): + def import_it(self, partname, fqname, parent, force_load=0): if not partname: raise ValueError, "Empty module name" - try: - return self.modules[fqname] - except KeyError: - pass + if not force_load: + try: + return self.modules[fqname] + except KeyError: + pass try: path = parent and parent.__path__ except AttributeError: @@ -489,11 +490,11 @@ def import_it(self, partname, fqname, parent): def reload(self, module): name = module.__name__ if '.' not in name: - return self.import_it(name, name, None) + return self.import_it(name, name, None, force_load=1) i = string.rfind(name, '.') pname = name[:i] parent = self.modules[pname] - return self.import_it(name[i+1:], name, parent) + return self.import_it(name[i+1:], name, parent, force_load=1) default_importer = None