aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBatuhan Taşkaya <47358913+isidentical@users.noreply.github.com>2020-01-02 21:20:04 +0300
committerPablo Galindo <Pablogsal@gmail.com>2020-01-02 18:20:04 +0000
commit7b35bef9787cd80ed1e12124f759b4be03c849db (patch)
tree6b9acbbb48a86fc49da74afc2c9a97f31373f6bc /Lib/ast.py
parentRemove outdated mention of hg.exe from Tools/msi/README.txt (GH-17792) (diff)
downloadcpython-7b35bef9787cd80ed1e12124f759b4be03c849db.tar.gz
cpython-7b35bef9787cd80ed1e12124f759b4be03c849db.tar.bz2
cpython-7b35bef9787cd80ed1e12124f759b4be03c849db.zip
bpo-38870: Throw ValueError on invalid yield from usage (GH-17798)
Diffstat (limited to 'Lib/ast.py')
-rw-r--r--Lib/ast.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/ast.py b/Lib/ast.py
index 62f6e075a09..ece8b139e46 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -735,10 +735,10 @@ class _Unparser(NodeVisitor):
def visit_YieldFrom(self, node):
with self.delimit("(", ")"):
- self.write("yield from")
- if node.value:
- self.write(" ")
- self.traverse(node.value)
+ self.write("yield from ")
+ if not node.value:
+ raise ValueError("Node can't be used without a value attribute.")
+ self.traverse(node.value)
def visit_Raise(self, node):
self.fill("raise")