This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ast.YieldFrom needlessly has its expr value as optional
Type: Stage: test needed
Components: Library (Lib) Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, brett.cannon, daniel.urban, jcea, mark.dickinson, python-dev
Priority: normal Keywords: patch

Created on 2012-11-23 22:42 by brett.cannon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue16546.patch mark.dickinson, 2012-11-24 18:11 review
issue16546_v2.patch mark.dickinson, 2012-11-25 09:55 review
Messages (8)
msg176261 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-11-23 22:42
The grammar guarantees that 'yield from' statements have an expression to evaluate, plus a 'yield from' without an expression makes no sense.
msg176269 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-11-24 08:46
Brett: can you clarify---in what sense is the argument optional?  I see that there's a doc issue at http://docs.python.org/dev/library/ast.html, where it's marked as optional but shouldn't but.  Is there something more that's wrong?

If you mean that ast.YieldFrom can be instantiated without an argument, isn't that the same for all the ast classes?

>>> ast.YieldFrom()
<_ast.YieldFrom object at 0x100760f50>
>>> ast.BoolOp()
<_ast.BoolOp object at 0x100760f90>
msg176288 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-11-24 14:21
Where is the doc issue? And it's a bit more than just a doc issue anyway as Python.asdl has the same issue and that is what is used to generate the code that represents the nodes.
msg176297 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-11-24 17:18
Ah, okay.  I only looked at Grammar/Grammar, which looks fine.

The doc issue is that at http://docs.python.org/dev/library/ast.html, under the heading "31.2.2. Abstract Grammar", it says:

  | Yield(expr? value)
             | YieldFrom(expr? value)

But the docs insert the contents of Python.asdl directly, so you're right: it's not really a doc issue.
msg176301 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-11-24 18:01
Here's a patch.
msg176302 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-11-24 18:11
New patch that removes some unnecessary braces in the case statements.
msg176333 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-11-25 09:55
New patch: move new test to the correct test class.
msg176360 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-25 14:40
New changeset ffb2fa900cb7 by Mark Dickinson in branch '3.3':
Issue #16546: make ast.YieldFrom argument mandatory.
http://hg.python.org/cpython/rev/ffb2fa900cb7

New changeset 9bc6e157475a by Mark Dickinson in branch 'default':
Issue #16546: merge fix from 3.3
http://hg.python.org/cpython/rev/9bc6e157475a
History
Date User Action Args
2022-04-11 14:57:38adminsetgithub: 60750
2012-11-26 17:25:24jceasetnosy: + jcea
2012-11-25 14:41:09mark.dickinsonsetstatus: open -> closed
resolution: fixed
2012-11-25 14:40:36python-devsetnosy: + python-dev
messages: + msg176360
2012-11-25 09:55:52mark.dickinsonsetfiles: + issue16546_v2.patch

messages: + msg176333
2012-11-24 18:11:39mark.dickinsonsetfiles: - issue16546.patch
2012-11-24 18:11:25mark.dickinsonsetfiles: + issue16546.patch

messages: + msg176302
2012-11-24 18:01:53mark.dickinsonsetfiles: + issue16546.patch
keywords: + patch
messages: + msg176301
2012-11-24 17:21:46mark.dickinsonsetnosy: + benjamin.peterson
2012-11-24 17:18:56mark.dickinsonsetmessages: + msg176297
2012-11-24 14:21:13brett.cannonsetmessages: + msg176288
2012-11-24 08:46:49mark.dickinsonsetnosy: + mark.dickinson
messages: + msg176269
2012-11-24 08:10:01daniel.urbansetnosy: + daniel.urban
2012-11-23 22:42:35brett.cannoncreate