ProgVal added the comment:
Indeed, thanks.
I should have done that when I migrated from compiler.parse.
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
Serhiy Storchaka added the comment:
If someone wants to parse a simple expression that may be a string he should
use the "eval" mode.
>>> ast.dump(ast.parse("'test'"))
"Module(body=[], docstring='test')"
>>> ast.dump(ast.parse("'test'", mode='eval'))
"Expression(body=Str(s='test'))"
ProgVal added the comment:
(Oops, submitted too soon.)
I understand the rational of this change, so I am not sure if this is actually
a bug.
However, if someone wants to parse a simple expression that may be a string,
they need to add a special handling in case it's a string interpreted as a
New submission from ProgVal:
Since commit cb41b2766de646435743b6af7dd152751b54e73f (Python 3.7a0), string
literals are not parsed the same way.
ast.parse("'test'").body used to be a list with one item containing 'test'; but
now it is an empty list:
Python 3.5.2+ (default, Dec 13 2016,