GH-117536: GH-117894: fix athrow().throw(...) unawaited warning#117851
GH-117536: GH-117894: fix athrow().throw(...) unawaited warning#117851encukou merged 15 commits intopython:mainfrom
Conversation
ccf9830 to
da89a69
Compare
797e0d5 to
f1ac5d3
Compare
|
This also fixes a bug where an athrow()/aclose() can be reused across StopIteration calls, so needs backporting to 3.12 |
|
Here's the repro: >>> class MyExc(Exception): pass
...
>>> import itertools
>>> async def gen():
... for i in itertools.count():
... try:
... yield i
... except MyExc:
... pass
...
>>> agen = gen()
>>> agen.asend(None).send(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration: 0
>>> athrow = agen.athrow(MyExc)
>>> athrow.throw(MyExc)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration: 1
>>> athrow.throw(MyExc)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration: 2
>>> athrow.throw(MyExc)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration: 3
>>> athrow.throw(MyExc)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration: 4
>>> |
Misc/NEWS.d/next/Core and Builtins/2024-04-13-16-55-53.gh-issue-117536.xkVbfv.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Core and Builtins/2024-04-13-16-55-53.gh-issue-117536.xkVbfv.rst
Outdated
Show resolved
Hide resolved
…e-117536.xkVbfv.rst
Misc/NEWS.d/next/Core and Builtins/2024-04-13-16-55-53.gh-issue-117536.xkVbfv.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Core and Builtins/2024-04-13-16-55-53.gh-issue-117536.xkVbfv.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Core and Builtins/2024-04-15-13-53-59.gh-issue-117894.8LpZ6m.rst
Outdated
Show resolved
Hide resolved
encukou
left a comment
There was a problem hiding this comment.
I'm not an expert in this area, but I cannot find anything wrong with the patch. An unhandled exception marking the awaitable closed (awaited) makes sense.
|
Let's merge this to fix the blocker issue. On #117882 I'll try to deepen my understanding of this code, so I can give a better review. |
|
This needs backporting to 3.12 |
|
Thanks @graingert for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Sorry, @graingert and @encukou, I could not cleanly backport this to |
|
GH-118226 is a backport of this pull request to the 3.12 branch. |
Uh oh!
There was an error while loading. Please reload this page.