summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2020-05-01 03:27:52 (GMT)
committerGitHub <noreply@github.com>2020-05-01 03:27:52 (GMT)
commit3e0a6f37dfdd595be737baae00ec0e036a912615 (patch)
tree42c810af16c6e84aa38aa31c30aebd1d0a9671f3 /Lib
parenteb0d359b4b0e14552998e7af771a088b4fd01745 (diff)
downloadcpython-3e0a6f37dfdd595be737baae00ec0e036a912615.zip
cpython-3e0a6f37dfdd595be737baae00ec0e036a912615.tar.gz
cpython-3e0a6f37dfdd595be737baae00ec0e036a912615.tar.bz2
bpo-40334: Add support for feature_version in new PEG parser (GH-19827)
`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/cpython#124.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_type_comments.py6
1 files changed, 0 insertions, 6 deletions
diff --git a/Lib/test/test_type_comments.py b/Lib/test/test_type_comments.py
index 6c3f6ed..6027b3b 100644
--- a/Lib/test/test_type_comments.py
+++ b/Lib/test/test_type_comments.py
@@ -252,7 +252,6 @@ class TypeCommentTests(unittest.TestCase):
self.assertEqual(tree.body[0].type_comment, None)
self.assertEqual(tree.body[1].type_comment, None)
- @support.skip_if_new_parser("Pegen does not support feature_version yet")
def test_asyncdef(self):
for tree in self.parse_all(asyncdef, minver=5):
self.assertEqual(tree.body[0].type_comment, "() -> int")
@@ -261,27 +260,22 @@ class TypeCommentTests(unittest.TestCase):
self.assertEqual(tree.body[0].type_comment, None)
self.assertEqual(tree.body[1].type_comment, None)
- @support.skip_if_new_parser("Pegen does not support feature_version yet")
def test_asyncvar(self):
for tree in self.parse_all(asyncvar, maxver=6):
pass
- @support.skip_if_new_parser("Pegen does not support feature_version yet")
def test_asynccomp(self):
for tree in self.parse_all(asynccomp, minver=6):
pass
- @support.skip_if_new_parser("Pegen does not support feature_version yet")
def test_matmul(self):
for tree in self.parse_all(matmul, minver=5):
pass
- @support.skip_if_new_parser("Pegen does not support feature_version yet")
def test_fstring(self):
for tree in self.parse_all(fstring, minver=6):
pass
- @support.skip_if_new_parser("Pegen does not support feature_version yet")
def test_underscorednumber(self):
for tree in self.parse_all(underscorednumber, minver=6):
pass