]> granicus.if.org Git - python/commitdiff
When recursively attempting to find the modules imported by an
authorGuido van Rossum <guido@python.org>
Mon, 16 Sep 2002 16:36:02 +0000 (16:36 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 16 Sep 2002 16:36:02 +0000 (16:36 +0000)
"import" statement, catch and ignore all exceptions.  add/fix some
comments about this.

Lib/pyclbr.py

index 1901a82be3198004054245f2e9c9907606973c57..fe34208dd65483c6ac5079ed6d39ab08821b0f7e 100644 (file)
@@ -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