Sjoerd Mullender:

When printing missing modules, also print the module they were
imported from.
This commit is contained in:
Guido van Rossum 1998-12-15 15:35:23 +00:00
parent 9c1696cff5
commit 38b92eb56a
2 changed files with 7 additions and 3 deletions

View File

@ -1 +1,2 @@
print 'Hello world...' print 'Hello world...'
import fooblurg

View File

@ -220,6 +220,7 @@ class ModuleFinder:
return m return m
if self.badmodules.has_key(fqname): if self.badmodules.has_key(fqname):
self.msgout(3, "import_module -> None") self.msgout(3, "import_module -> None")
self.badmodules[fqname][parent.__name__] = None
return None return None
try: try:
fp, pathname, stuff = self.find_module(partname, fp, pathname, stuff = self.find_module(partname,
@ -279,7 +280,7 @@ class ModuleFinder:
self.import_hook(name, m) self.import_hook(name, m)
except ImportError, msg: except ImportError, msg:
self.msg(2, "ImportError:", str(msg)) self.msg(2, "ImportError:", str(msg))
self.badmodules[name] = None self.badmodules[name] = {m.__name__:None}
elif op == IMPORT_FROM: elif op == IMPORT_FROM:
name = co.co_names[oparg] name = co.co_names[oparg]
assert lastname is not None assert lastname is not None
@ -289,7 +290,7 @@ class ModuleFinder:
except ImportError, msg: except ImportError, msg:
self.msg(2, "ImportError:", str(msg)) self.msg(2, "ImportError:", str(msg))
fullname = lastname + "." + name fullname = lastname + "." + name
self.badmodules[fullname] = None self.badmodules[fullname] = {m.__name__:None}
else: else:
lastname = None lastname = None
for c in co.co_consts: for c in co.co_consts:
@ -361,7 +362,9 @@ class ModuleFinder:
for key in keys: for key in keys:
# ... but not if they were explicitely excluded. # ... but not if they were explicitely excluded.
if key not in self.excludes: if key not in self.excludes:
print "?", key mods = self.badmodules[key].keys()
mods.sort()
print "?", key, "from", string.join(mods, ', ')
def test(): def test():