When recursively attempting to find the modules imported by an
"import" statement, catch and ignore all exceptions. add/fix some comments about this.
This commit is contained in:
parent
f1fe145d20
commit
258cba8442
@ -219,16 +219,24 @@ def readmodule_ex(module, path=[], inpackage=False):
|
|||||||
elif token == 'import' and start[1] == 0:
|
elif token == 'import' and start[1] == 0:
|
||||||
modules = _getnamelist(g)
|
modules = _getnamelist(g)
|
||||||
for mod, mod2 in modules:
|
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:
|
elif token == 'from' and start[1] == 0:
|
||||||
mod, token = _getname(g)
|
mod, token = _getname(g)
|
||||||
if not mod or token != "import":
|
if not mod or token != "import":
|
||||||
continue
|
continue
|
||||||
names = _getnamelist(g)
|
names = _getnamelist(g)
|
||||||
try:
|
try:
|
||||||
# recursively read the imported module
|
# Recursively read the imported module
|
||||||
d = readmodule_ex(mod, path, inpackage)
|
d = readmodule_ex(mod, path, inpackage)
|
||||||
except:
|
except:
|
||||||
|
# If we can't find or parse the imported module,
|
||||||
|
# too bad -- don't die here.
|
||||||
continue
|
continue
|
||||||
# add any classes that were defined in the imported module
|
# add any classes that were defined in the imported module
|
||||||
# to our name space if they were mentioned in the list
|
# to our name space if they were mentioned in the list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user