Crash when analyzing files of different Python versions
Solumin opened this issue · 0 comments
Solumin commented
Input:
# file a.py
import b
# file b.py
raise 1, 2, 3 # Python 2 syntax
Output of -V2.7:
$ importlab -V2.7 -P. *.py --tree
Source tree:
+ a.py
+ b.py
Output of -V3.6:
$ importlab -V3.6 -P. *.py --tree
Traceback (most recent call last):
File "/usr/bin/importlab", line 69, in <module>
sys.exit(main())
File "/usr/bin/importlab", line 53, in main
import_graph = graph.ImportGraph.create(env, args.filenames)
File "/usr/local/lib/python2.7/site-packages/importlab/graph.py", line 248, in create
import_graph.add_file_recursive(os.path.abspath(filename))
File "/usr/local/lib/python2.7/site-packages/importlab/graph.py", line 123, in add_file_recursive
deps, broken = self.get_file_deps(filename)
File "/usr/local/lib/python2.7/site-packages/importlab/graph.py", line 262, in get_file_deps
for imp in parsepy.get_imports(filename, self.env.python_version):
File "/usr/local/lib/python2.7/site-packages/importlab/parsepy.py", line 90, in get_imports
raise Exception('parse error for ' + filename)
Exception: parse error for /tmp/imptest/b.py
It would be nice if importlab didn't crash here. I think a --keep-going
option would be useful for some users.