mirror of https://github.com/python/cpython
bpo-38870: Throw ValueError on invalid yield from usage (GH-17798)
This commit is contained in:
parent
78018bb162
commit
7b35bef978
|
@ -736,8 +736,8 @@ class _Unparser(NodeVisitor):
|
|||
def visit_YieldFrom(self, node):
|
||||
with self.delimit("(", ")"):
|
||||
self.write("yield from ")
|
||||
if node.value:
|
||||
self.write(" ")
|
||||
if not node.value:
|
||||
raise ValueError("Node can't be used without a value attribute.")
|
||||
self.traverse(node.value)
|
||||
|
||||
def visit_Raise(self, node):
|
||||
|
|
|
@ -278,6 +278,8 @@ class UnparseTestCase(ASTTestCase):
|
|||
def test_invalid_set(self):
|
||||
self.check_invalid(ast.Set(elts=[]))
|
||||
|
||||
def test_invalid_yield_from(self):
|
||||
self.check_invalid(ast.YieldFrom(value=None))
|
||||
|
||||
class DirectoryTestCase(ASTTestCase):
|
||||
"""Test roundtrip behaviour on all files in Lib and Lib/test."""
|
||||
|
|
Loading…
Reference in New Issue