Syntax error in package raises uncaught exception
Opened this issue · 1 comments
tallforasmurf commented
turns out, ast.parse() can raise a syntax error, so the try at line 50 should have a second except to catch errors other than IO error.
In the following, the package code that causes the error was not executed when the interpreter is Python 3, but ast doesn't know that. Actually turns out it isn't even in the current level of PyInstaller, so don't bother trying to reproduce. Just the general point, ast.parse() is capable of throwing a syntax error.
python -m blackwidow.web PyInstaller
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/web.py", line 99, in <module>
web = Web(project_path, exclude=args.exclude)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/web.py", line 27, in __init__
Node(file, package_root=self.package_root) for file in self.files
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/web.py", line 27, in <listcomp>
Node(file, package_root=self.package_root) for file in self.files
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/node.py", line 21, in __init__
self.edges = imported_modules(filename, package_root=package_root)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/imports.py", line 52, in imported_modules
tree = ast.parse(fd.read(), filename=filename)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/lib/pefile_py2.py", line 82
IMAGE_ORDINAL_FLAG = 0x80000000L
^
SyntaxError: invalid syntax
tallforasmurf commented
Actually if you pip install --upgrade PyInstaller
and graph it? It's a very pretty graph, although it is way big.