berkerpeksag / astor

Python AST read/write
https://pypi.org/project/astor/
BSD 3-Clause "New" or "Revised" License
810 stars 102 forks source link

AttributeError: 'ClassDef' object has no attribute 'starargs' #178

Open Joejiong opened 4 years ago

Joejiong commented 4 years ago

Hi astors,

I met the following problem when I exec following code to parse another program file.

r2 = gast.gast_to_ast(root2) print(astor.to_source(r2))

and my env: python3.7

error: AttributeError: 'ClassDef' object has no attribute 'starargs'

context:


AttributeError Traceback (most recent call last)

in 1 r2 = gast.gast_to_ast(root2) ----> 2 print(astor.to_source(r2)) /opt/anaconda3/lib/python3.7/site-packages/astor/codegen.py in to_source(node, indent_with, add_line_information) 38 """ 39 generator = SourceGenerator(indent_with, add_line_information) ---> 40 generator.visit(node) 41 return ''.join(str(s) for s in generator.result) 42 /opt/anaconda3/lib/python3.7/site-packages/astor/misc.py in visit(self, node, abort) 159 method = 'visit_' + node.__class__.__name__ 160 visitor = getattr(self, method, abort) --> 161 return visitor(node) 162 163 /opt/anaconda3/lib/python3.7/site-packages/astor/codegen.py in visit_Module(self, node) 491 def visit_Module(self, node): 492 for stmt in node.body: --> 493 self.visit(stmt) 494 495 # Helper Nodes /opt/anaconda3/lib/python3.7/site-packages/astor/misc.py in visit(self, node, abort) 159 method = 'visit_' + node.__class__.__name__ 160 visitor = getattr(self, method, abort) --> 161 return visitor(node) 162 163 /opt/anaconda3/lib/python3.7/site-packages/astor/codegen.py in visit_ClassDef(self, node) 208 for keyword in node.keywords: 209 self.write(paren_or_comma, keyword.arg, '=', keyword.value) --> 210 self.conditional_write(paren_or_comma, '*', node.starargs) 211 self.conditional_write(paren_or_comma, '**', node.kwargs) 212 self.write(have_args and '):' or ':') AttributeError: 'ClassDef' object has no attribute 'starargs'