[New-bugs-announce] [issue39463] ast.Constant, bytes, and ast.unparse
report at bugs.python.org
Mon Jan 27 06:40:03 EST 2020
New submission from Tal Ben-Nun <tbennun at gmail.com>:
In Python 3.8, the "kind" field was introduced into the Constant AST class. This brings about a problem when unparsing the AST for various packages. First, it breaks backward compatibility for older code that creates ast.Num without specifying kind (which is optional anyway and does not exist in its fields). Second, since bytes are parsed as a Constant without a kind, one can create the following (valid as of now) AST and unparse it:
Getting "ub'bad'", which is invalid Python syntax AFAIU.
Could something be done with the classes that extend ast.Constant and with bytes being a Constant with a "kind" of "b"?
components: Library (Lib)
nosy: Tal Ben-Nun
title: ast.Constant, bytes, and ast.unparse
versions: Python 3.9
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce