berkerpeksag / astor

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

astor.code_to_ast fails with KeyError on decorated functions in Python 3.8.1 #174

Closed dcharbon closed 3 years ago

dcharbon commented 4 years ago

The line number for codeobj is reported as the line number of the last processed decorator for the function for decorated functions. The line number reported for the FunctionDef on parse is the actual line number of the function declaration, e.g. def funcname, leading to a mismatch and a KeyError on attempting to return the ast for the codeobj.