mirror of https://github.com/python/cpython.git
Thomas Heller <thomas.heller@ion-tof.com>:
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.
This commit is contained in:
parent
10dfd4c1c3
commit
8deecedc6d
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue