Open sanjit-bhat opened 3 years ago
Note: it looks like simply commenting out that assertion doesn't work. While it passes the AST Generalization phase, the unparser then throws this error:
Traceback (most recent call last):
File "test.py", line 11, in <module>
c_code = translator.translate(code, path)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/transpyle/general/translator.py", line 27, in translate
to_code = self.unparser.unparse(general_ast, **unparser_kwargs)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/transpyle/python/unparser.py", line 45, in unparse
code = horast.unparse(tree)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/horast/unparser.py", line 159, in unparse
Unparser(tree, *args, file=stream, **kwargs)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/astunparse/unparser.py", line 38, in __init__
self.dispatch(tree)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/static_typing/unparser.py", line 21, in dispatch
super().dispatch(tree)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/astunparse/unparser.py", line 66, in dispatch
meth(tree)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/astunparse/unparser.py", line 78, in _Module
self.dispatch(stmt)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/static_typing/unparser.py", line 21, in dispatch
super().dispatch(tree)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/astunparse/unparser.py", line 66, in dispatch
meth(tree)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/astunparse/unparser.py", line 347, in _FunctionDef
self.__FunctionDef_helper(t, "def")
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/astunparse/unparser.py", line 359, in __FunctionDef_helper
self.dispatch(t.args)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/static_typing/unparser.py", line 21, in dispatch
super().dispatch(tree)
File "/Users/sanjit/.pyenv/versions/3.8.1/lib/python3.8/site-packages/astunparse/unparser.py", line 65, in dispatch
meth = getattr(self, "_"+tree.__class__.__name__)
AttributeError: 'Unparser' object has no attribute '_NoneType'
TLDR: If you run the Transpyler AST Generalizer on a C program with
void
functions, it will throw anisinstance
assertion error becausepycparser
returnsNone
for the function declaration, while the AST Generalizer expects atyped_ast3.arguments
type. Here's a link to the relevant Transpyler function.Minimal code example:
with
my_script.c
set toMy traceback is