summaryrefslogtreecommitdiffstats
path: root/Lib/pyclbr.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-09-16 16:36:02 (GMT)
committerGuido van Rossum <guido@python.org>2002-09-16 16:36:02 (GMT)
commit258cba8442e5443e689c4ae371f30eb541d05f93 (patch)
tree80a46944c995462ad22c97e04e16afc401c7a660 /Lib/pyclbr.py
parentf1fe145d20eca65c4bb684115fc377dc9f5c8855 (diff)
downloadcpython-258cba8442e5443e689c4ae371f30eb541d05f93.zip
cpython-258cba8442e5443e689c4ae371f30eb541d05f93.tar.gz
cpython-258cba8442e5443e689c4ae371f30eb541d05f93.tar.bz2
When recursively attempting to find the modules imported by an
"import" statement, catch and ignore all exceptions. add/fix some comments about this.
Diffstat (limited to 'Lib/pyclbr.py')
-rw-r--r--Lib/pyclbr.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/pyclbr.py b/Lib/pyclbr.py
index 1901a82..fe34208 100644
--- a/Lib/pyclbr.py
+++ b/Lib/pyclbr.py
@@ -219,16 +219,24 @@ def readmodule_ex(module, path=[], inpackage=False):
elif token == 'import' and start[1] == 0:
modules = _getnamelist(g)
for mod, mod2 in modules:
- readmodule_ex(mod, path, inpackage)
+ try:
+ # Recursively read the imported module
+ readmodule_ex(mod, path, inpackage)
+ except:
+ # If we can't find or parse the imported module,
+ # too bad -- don't die here.
+ pass
elif token == 'from' and start[1] == 0:
mod, token = _getname(g)
if not mod or token != "import":
continue
names = _getnamelist(g)
try:
- # recursively read the imported module
+ # Recursively read the imported module
d = readmodule_ex(mod, path, inpackage)
except:
+ # If we can't find or parse the imported module,
+ # too bad -- don't die here.
continue
# add any classes that were defined in the imported module
# to our name space if they were mentioned in the list