-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed as not planned
Description
I own some code that has been forwarding throw by declaring a three-parameter method with two defaulted to None, but as of py3.11 we have started seeing errors:
TypeError: throw() third argument must be a traceback
This doesn't seem to match the type stubs. Should the second Coroutine.throw overload be changed to remove the final | None?
Line 406 in a9b4fa0
| def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... |
Minimal repro
(Must be run in py3.11)
>>> import asyncio
>>> async def f():
... await asyncio.sleep(0)
>>> async def g():
... await asyncio.gather(f(), f())
>>> h = g()
>>> h.send(None)
<stdin>:2: DeprecationWarning: There is no current event loop
<_GatheringFuture pending>
>>> h.throw(ValueError("some error"), None, None)
Traceback (most recent call last):
...
TypeError: throw() third argument must be a tracebackNotes:
- this does not happen if you instead do
h = f(), nor if you skip theh.send(None), so there is something important about theasyncio.gather. - if you run this in py3.10, you will get
ValueError: some error, so this is a behaviour change in 3.11. - Possibly this is caused by python/cpython@0a8b8e0 ?
Metadata
Metadata
Assignees
Labels
No labels