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 <>
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)
>>> ast.dump(ast.parse(ast.unparse(constant_tuple))) != ast.dump(constant_tuple)
>>> ast.dump(ast.parse(ast.unparse(constant_tuple))) == ast.dump(normalpy_tuple)

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.
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: <>
2020-01-07 11:25:14BTaskayalinkissue38870 messages
2020-01-07 11:25:14BTaskayacreate