This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jez
Recipients docs@python, jez, steven.daprano
Date 2019-01-21.18:15:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1548094553.76.0.712322563821.issue35777@roundup.psfhosted.org>
In-reply-to
Content
I take the point about breaking backward compatibility. The problem, then, is in the `ast` documentation, and may not be confined to Python 2.7

The `literal_eval` doc <https://docs.python.org/2/library/ast.html#ast-helpers> states no more than that the function evaluates a "string containing a Python literal".  The future statement effectively changes the definition of "a Python literal" but of course, as the official `__future__` doc <https://docs.python.org/2/reference/simple_stmts.html#future> explains, this is done for the compilation of each "particular module" in isolation. The question is left open whether the occurrence of this term in `ast` documentation should be read as "a Python literal (as defined by the ast module itself at compile time)",  or "a Python literal (as defined by the caller at compile time)".

More generally, future statements effectively change the definition of the term "Python syntax", sometimes also simply referred to as "Python".  Unfortunately, the `ast` documentation uses these terms loosely throughout, without acknowledging that they are mutable. I propose that the `ast` module documentation flag cases in which the `ast` module's own definitions of "Python" and "Python syntax" may not match those of a caller who has included `__future__` statements, leading to unexpected behavior.

I am insufficiently familiar with the full functionality of `ast` to be able to identify where this is and is not an issue, except in `literal_eval`, but I can see it could in principle affect Python 3.x too.
History
Date User Action Args
2019-01-21 18:15:55jezsetrecipients: + jez, steven.daprano, docs@python
2019-01-21 18:15:53jezsetmessageid: <1548094553.76.0.712322563821.issue35777@roundup.psfhosted.org>
2019-01-21 18:15:53jezlinkissue35777 messages
2019-01-21 18:15:53jezcreate