berkerpeksag / astor

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

AttributeError: No defined handler for node of type Match #215

Closed avelican closed 6 months ago

avelican commented 1 year ago

Here are the relevant error messages, triggered by astor.to_source(tree)

  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 63, in to_source
    generator.visit(node)
  File "C:\py\Python311\Lib\site-packages\astor\node_util.py", line 143, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 335, in visit_FunctionDef
    self.body(node.body)
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 226, in body
    self.write(*statements)
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 178, in write
    visit(item)
  File "C:\py\Python311\Lib\site-packages\astor\node_util.py", line 143, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 397, in visit_While
    self.body_or_else(node)
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 235, in body_or_else
    self.body(node.body)
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 226, in body
    self.write(*statements)
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 178, in write
    visit(item)
  File "C:\py\Python311\Lib\site-packages\astor\node_util.py", line 143, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 388, in visit_For
    self.body_or_else(node)
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 235, in body_or_else
    self.body(node.body)
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 226, in body
    self.write(*statements)
  File "C:\py\Python311\Lib\site-packages\astor\code_gen.py", line 178, in write
    visit(item)
  File "C:\py\Python311\Lib\site-packages\astor\node_util.py", line 143, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "C:\py\Python311\Lib\site-packages\astor\node_util.py", line 137, in abort_visit
    raise AttributeError(msg % node.__class__.__name__)
AttributeError: No defined handler for node of type Match
berkerpeksag commented 1 year ago

Thank you for the report. This probably requires implementing PEP 634 support.

just2husky commented 6 months ago

Hi all, I use astor to process code, and encounter this problem. It seems this issue was solved at Apr 19, 2023, but the lasted version is 0.8.1 which released at on Dec 10, 2019. I would like to ask when the new version will be released?

Best