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: Symbol table incorrectly identifies code as a generator, when 'yield' occurs in an annotation
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Mark.Shannon Nosy List: BTaskaya, Mark.Shannon, gvanrossum, larry, lys.nikolaou, pablogsal, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2021-01-06 09:51 by Mark.Shannon, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24138 closed Mark.Shannon, 2021-01-06 10:15
Messages (10)
msg384479 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-01-06 09:51
This is an internal inconsistency. I have not identified any surface level bugs, but it is a trap for future compiler work.
msg384480 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-06 09:59
This is a duplicate of issue42725.
msg384482 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-01-06 10:05
No this is not a duplicate.
This is about making the symbol table correct for current semantics.
#42725 is about changing the behavior
msg384484 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-06 10:32
Does not it change the current behavior? I do not see a difference with issue42725.

>>> def f():
...     x: (yield)
... 
>>> f()
<generator object f at 0x7f971b45d950>
msg384489 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-01-06 11:00
The aim is to change the behavior of the symbol table to match the compiler.
The behavior has already changed at module scope.

Python 3.9.0+
>>> x:(yield None)
  File "<stdin>", line 1
SyntaxError: 'yield' outside function
>>> 


Python 3.10.0a4+
>>> x:(yield None)
>>>
msg384491 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-06 11:29
Then why not fix the compiler?

As I understand, it is not clear yet what behavior should be, and discussing it is the matter of issue42725. Any changes before the decision be made are preliminary.

It is very likely that the decision will be in favor of ignoring annotations. In that case your PR or even more radical changes can be merged.
msg384495 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-01-06 12:03
OK, I won't merge anything yet.
msg384612 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2021-01-07 22:24
Well even though I still don't understand 'how this issue is different than issue42725', I don't think you actually fix the symbol table;
see this one: https://bugs.python.org/msg383659

Annotations still have side effects on the symbol table (even though they shouldn't have). and I already had a fix but decided not to go for it until issue42737 is resolved since it would make the language inconsistent. Just FYI.
msg399504 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-08-13 08:34
I guess this will be resolved when the great PEP 563/649 debate is concluded. No need for another issue.
msg399508 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2021-08-13 08:52
AFAIK this is already resolved on the main (https://bugs.python.org/issue42725)
History
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 87003
2021-08-13 08:52:25BTaskayasetmessages: + msg399508
2021-08-13 08:34:19Mark.Shannonsetstatus: open -> closed
resolution: duplicate
messages: + msg399504

stage: patch review -> resolved
2021-01-07 22:24:28BTaskayasetmessages: + msg384612
2021-01-07 22:14:16BTaskayasetnosy: + BTaskaya
2021-01-06 15:39:18gvanrossumsetnosy: + gvanrossum, lys.nikolaou, pablogsal
2021-01-06 12:03:37Mark.Shannonsetmessages: + msg384495
2021-01-06 11:29:05serhiy.storchakasetmessages: + msg384491
2021-01-06 11:00:10Mark.Shannonsetmessages: + msg384489
2021-01-06 10:32:26serhiy.storchakasetmessages: + msg384484
2021-01-06 10:15:28Mark.Shannonsetkeywords: + patch
stage: resolved -> patch review
pull_requests: + pull_request22967
2021-01-06 10:05:22Mark.Shannonsetstatus: closed -> open
resolution: duplicate -> (no value)
superseder: PEP 563: Should the behavior change for yield/yield from's ->
messages: + msg384482
2021-01-06 09:59:23serhiy.storchakasetstatus: open -> closed

superseder: PEP 563: Should the behavior change for yield/yield from's

nosy: + serhiy.storchaka
messages: + msg384480
resolution: duplicate
stage: resolved
2021-01-06 09:51:20Mark.Shannoncreate