Skip to content

Regression in Python 3.11 when explicitly passing None to FutureIter.throw #101326

Closed
@hauntsaninja

Description

@hauntsaninja

Reported and commit identified by @alicederyn in python/typeshed#9586

Regression caused by #31973. Doesn't contain a news entry, so probably not intentional.

λ cat xxx.py
import asyncio
async def f():
  await asyncio.sleep(0)
async def g():
  await asyncio.gather(f(), f())

h = g()
h.send(None)
print(type(h))
h.throw(ValueError("some error"), None, None)

λ python3.10 xxx.py
/Users/shantanu/dev/cpython/xxx.py:5: DeprecationWarning: There is no current event loop
  await asyncio.gather(f(), f())
<class 'coroutine'>
Traceback (most recent call last):
  File "/Users/shantanu/dev/cpython/xxx.py", line 10, in <module>
    h.throw(ValueError("some error"), None, None)
  File "/Users/shantanu/dev/cpython/xxx.py", line 5, in g
    await asyncio.gather(f(), f())
ValueError: some error

λ python3.11 xxx.py
/Users/shantanu/dev/cpython/xxx.py:5: DeprecationWarning: There is no current event loop
  await asyncio.gather(f(), f())
<class 'coroutine'>
Traceback (most recent call last):
  File "/Users/shantanu/dev/cpython/xxx.py", line 10, in <module>
    h.throw(ValueError("some error"), None, None)
  File "/Users/shantanu/dev/cpython/xxx.py", line 5, in g
    await asyncio.gather(f(), f())
TypeError: throw() third argument must be a traceback

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions