Author BTaskaya
Recipients BTaskaya, Batuhan Taskaya, brandtbucher, brett.cannon, levkivskyi, miss-islington, pablogsal, vstinner
Date 2020-01-07.11:25:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578396315.01.0.12206591729.issue38870@roundup.psfhosted.org>
In-reply-to
Content
We might need to tweak the documentation @pablogsal, 

> Unparse an ast.AST object and generate a string with code that would produce an equivalent ast.AST object if parsed back with ast.parse().

If I interpret `equivalent` correctly, this explanation is false under cases like constant nodes has an immutable container value (which they can). 

>>> def wrap(expr):
...     return ast.Module(body=[ast.Expr(expr)], type_ignores=[])
... 
>>> constant_tuple = wrap(ast.Constant(value=(1, 2, 3), kind=None))
>>> normalpy_tuple = ast.parse("(1, 2, 3)")
>>> ast.unparse(constant_tuple) == ast.unparse(normalpy_tuple)
True
>>> ast.dump(ast.parse(ast.unparse(constant_tuple))) != ast.dump(constant_tuple)
True
>>> ast.dump(ast.parse(ast.unparse(constant_tuple))) == ast.dump(normalpy_tuple)
True

This isn't a bug in the code because there is no way we can generate a string that can produce a constant tuple. But this makes the docstring false, at least in certain cases.
History
Date User Action Args
2020-01-07 11:25:15BTaskayasetrecipients: + BTaskaya, brett.cannon, vstinner, levkivskyi, pablogsal, miss-islington, brandtbucher, Batuhan Taskaya
2020-01-07 11:25:15BTaskayasetmessageid: <1578396315.01.0.12206591729.issue38870@roundup.psfhosted.org>
2020-01-07 11:25:14BTaskayalinkissue38870 messages
2020-01-07 11:25:14BTaskayacreate