Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when analyzing files of different Python versions #16

Closed
Solumin opened this issue Aug 22, 2018 · 0 comments
Closed

Crash when analyzing files of different Python versions #16

Solumin opened this issue Aug 22, 2018 · 0 comments

Comments

@Solumin
Copy link
Contributor

Solumin commented Aug 22, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant