From 439f8cbfe0b5d1f931c2233d1790e1280170c24c Mon Sep 17 00:00:00 2001 From: Jan Paul Batrina Date: Sat, 28 Aug 2021 21:27:41 +0800 Subject: [PATCH] Python: Add "yield from" keyword BUG: 441540 --- autotests/folding/test.py.fold | 9 +++++++++ autotests/html/test.py.dark.html | 9 +++++++++ autotests/html/test.py.html | 9 +++++++++ autotests/input/test.py | 9 +++++++++ autotests/reference/test.py.ref | 9 +++++++++ data/syntax/python.xml | 17 +++++++++++++++-- 6 files changed, 60 insertions(+), 2 deletions(-) diff --git a/autotests/folding/test.py.fold b/autotests/folding/test.py.fold index 7bbf054c..5e7a3ba8 100644 --- a/autotests/folding/test.py.fold +++ b/autotests/folding/test.py.fold @@ -118,6 +118,15 @@ match(command.split(["quit"]: print("Goodbye!") +def func1(): + yield 1 + yield from [func(), 1, 2, "3"] + # invalid, "from" no longer part of "yield from" + yield, from 1 + +async def func2(): + await asyncio.sleep(1) + "\\\\\\\\\\ENSURE THAT THIS AND THE FOLLOWING LINES ARE AT THE END OF THE FILE\\\\\\\\\\ \ " a = 'otherwise all succeeding lines will be diff --git a/autotests/html/test.py.dark.html b/autotests/html/test.py.dark.html index 23718b11..1d6c1dd2 100644 --- a/autotests/html/test.py.dark.html +++ b/autotests/html/test.py.dark.html @@ -124,6 +124,15 @@ match(command.split()) case ["quit"]: print("Goodbye!") +def func1(): + yield 1 + yield from [func(), 1, 2, "3"] + # invalid, "from" no longer part of "yield from" + yield, from 1 + +async def func2(): + await asyncio.sleep(1) + "\\\\\\\\\\ENSURE THAT THIS AND THE FOLLOWING LINES ARE AT THE END OF THE FILE\\\\\\\\\\ \ " a = 'otherwise all succeeding lines will be diff --git a/autotests/html/test.py.html b/autotests/html/test.py.html index 55cfefb0..4d7a2709 100644 --- a/autotests/html/test.py.html +++ b/autotests/html/test.py.html @@ -124,6 +124,15 @@ match(command.split()) case ["quit"]: print("Goodbye!") +def func1(): + yield 1 + yield from [func(), 1, 2, "3"] + # invalid, "from" no longer part of "yield from" + yield, from 1 + +async def func2(): + await asyncio.sleep(1) + "\\\\\\\\\\ENSURE THAT THIS AND THE FOLLOWING LINES ARE AT THE END OF THE FILE\\\\\\\\\\ \ " a = 'otherwise all succeeding lines will be diff --git a/autotests/input/test.py b/autotests/input/test.py index 3eb8378d..d91db578 100644 --- a/autotests/input/test.py +++ b/autotests/input/test.py @@ -118,6 +118,15 @@ match(command.split()): case ["quit"]: print("Goodbye!") +def func1(): + yield 1 + yield from [func(), 1, 2, "3"] + # invalid, "from" no longer part of "yield from" + yield, from 1 + +async def func2(): + await asyncio.sleep(1) + "\\\\\\\\\\ENSURE THAT THIS AND THE FOLLOWING LINES ARE AT THE END OF THE FILE\\\\\\\\\\ \ " a = 'otherwise all succeeding lines will be diff --git a/autotests/reference/test.py.ref b/autotests/reference/test.py.ref index 9c5bdb54..1742da2b 100644 --- a/autotests/reference/test.py.ref +++ b/autotests/reference/test.py.ref @@ -118,6 +118,15 @@ case ["quit"]:
print("Goodbye!")

+def func1():
+ yield 1
+ yield from [func(), 1, 2, "3"]
+ # invalid, "from" no longer part of "yield from"
+ yield, from 1
+
+async def func2():
+ await asyncio.sleep(1)
+
"\\\\\\\\\\ENSURE THAT THIS AND THE FOLLOWING LINES ARE AT THE END OF THE FILE\\\\\\\\\\ \
"
a = 'otherwise all succeeding lines will be
diff --git a/data/syntax/python.xml b/data/syntax/python.xml index 7143bf30..676872f0 100644 --- a/data/syntax/python.xml +++ b/data/syntax/python.xml @@ -52,7 +52,7 @@ - + import @@ -90,10 +90,17 @@ try while with - yield async await + + yield + + yield from + match case @@ -380,6 +387,7 @@ + @@ -428,6 +436,11 @@ + + + + +