-
Notifications
You must be signed in to change notification settings - Fork 52
'astunparse.unparse' error with Python 3.8.1 #43
Copy link
Copy link
Closed
Description
Hi,
The following code throws an error when it parses a constant inside some_code:
astunparse.unparse(some_code)The traceback is:
File "test_astunparse.py", line 236, in process_code
result = astunparse.unparse(some_code)
File "C:\Python38\lib\site-packages\astunparse\__init__.py", line 13, in unparse
Unparser(tree, file=v)
File "C:\Python38\lib\site-packages\astunparse\unparser.py", line 38, in __init__
self.dispatch(tree)
File "C:\Python38\lib\site-packages\astunparse\unparser.py", line 66, in dispatch
meth(tree)
File "C:\Python38\lib\site-packages\astunparse\unparser.py", line 78, in _Module
self.dispatch(stmt)
File "C:\Python38\lib\site-packages\astunparse\unparser.py", line 66, in dispatch
meth(tree)
File "C:\Python38\lib\site-packages\astunparse\unparser.py", line 347, in _FunctionDef
self.__FunctionDef_helper(t, "def")
File "C:\Python38\lib\site-packages\astunparse\unparser.py", line 359, in __FunctionDef_helper
self.dispatch(t.args)
File "C:\Python38\lib\site-packages\astunparse\unparser.py", line 66, in dispatch
meth(tree)
File "C:\Python38\lib\site-packages\astunparse\unparser.py", line 791, in _arguments
self.dispatch(d)
File "C:\Python38\lib\site-packages\astunparse\unparser.py", line 66, in dispatch
meth(tree)
File "C:\Python38\lib\site-packages\astunparse\unparser.py", line 551, in _Constant
if t.kind == "u":
AttributeError: 'Constant' object has no attribute 'kind'
A hack that fixes this is to comment out line 551 and 552 in C:\Python38\lib\site-packages\astunparse\unparser.py, like so:
elif value is Ellipsis: # instead of `...` for Py2 compatibility
self.write("...")
else:
# if t.kind == "u":
# self.write("u")
self._write_constant(t.value)Regards
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels