{{ message }}
bpo-40334: Add support for feature_version in new PEG parser#19827
Merged
gvanrossum merged 2 commits intoMay 1, 2020
Merged
Conversation
`ast.parse` and `compile` support a `feature_version` parameter that tells the parser to parse the input string, as if it were written in an older Python version. The `feature_version` is propagated to the tokenizer, which uses it to handle the three different stages of support for `async` and `await`. Additionally, it disallows the following at parser level: - The '@' operator in < 3.5 - Async functions in < 3.5 - Async comprehensions in < 3.6 - Underscores in numeric literals in < 3.6 - Await expression in < 3.5 - Variable annotations in < 3.6 - Async for-loops in < 3.5 - Async with-statements in < 3.5 - F-strings in < 3.6 Closes we-like-parsers#124.
gvanrossum
approved these changes
May 1, 2020
gvanrossum
left a comment
Member
There was a problem hiding this comment.
Thanks! This looks pretty straightforward.
Sorry, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.
ast.parseandcompilesupport afeature_versionparameter thattells the parser to parse the input string, as if it were written in
an older Python version.
The
feature_versionis propagated to the tokenizer, which uses itto handle the three different stages of support for
asyncandawait. Additionally, it disallows the following at parser level:Closes we-like-parsers#124.
https://bugs.python.org/issue40334