Skip to content
Snippets Groups Projects
Commit b286f9e6fe0b authored by Batuhan Taşkaya's avatar Batuhan Taşkaya
Browse files

bpo-38870: Throw ValueError on invalid yield from usage (GH-17798)

parent 12edceb2bde3
Branches
No related tags found
No related merge requests found
...@@ -736,8 +736,8 @@ ...@@ -736,8 +736,8 @@
def visit_YieldFrom(self, node): def visit_YieldFrom(self, node):
with self.delimit("(", ")"): with self.delimit("(", ")"):
self.write("yield from ") self.write("yield from ")
if node.value: if not node.value:
self.write(" ") raise ValueError("Node can't be used without a value attribute.")
self.traverse(node.value) self.traverse(node.value)
def visit_Raise(self, node): def visit_Raise(self, node):
......
...@@ -278,6 +278,8 @@ ...@@ -278,6 +278,8 @@
def test_invalid_set(self): def test_invalid_set(self):
self.check_invalid(ast.Set(elts=[])) self.check_invalid(ast.Set(elts=[]))
def test_invalid_yield_from(self):
self.check_invalid(ast.YieldFrom(value=None))
class DirectoryTestCase(ASTTestCase): class DirectoryTestCase(ASTTestCase):
"""Test roundtrip behaviour on all files in Lib and Lib/test.""" """Test roundtrip behaviour on all files in Lib and Lib/test."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment