Skip to content

coverage seems to cause coroutines to skip over exeption handlers on 3.12 #1635

Closed
@graingert

Description

@graingert

urllib3/urllib3#3049 (comment)

Describe the bug
when running on 3.12b1 and coverage 7.2.7 (with C extension) coverage seems to cause coroutines to skip over exeption handlers

To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:

  1. What version of Python are you using? 3.12b1
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful. 7.2.7
  3. What versions of what packages do you have installed? The output of pip freeze is helpful.
  4. What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix. Python 3.12 Support urllib3/urllib3#3049 (comment)

input:

import asyncio

async def inner():
    loop = asyncio.get_running_loop()
    fut = loop.create_future()
    loop.call_later(0.1, fut.set_exception, Exception())
    try:
        await fut
    except Exception:
        print("good")

async def main():
    await inner()

asyncio.run(main())

Expected behavior

 graingert@conscientious  ~/projects/urllib3   py3-12-debug ± ./.nox/test-3-12/bin/coverage run -m demo
Traceback (most recent call last):
  File "/home/graingert/projects/urllib3/demo.py", line 15, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/graingert/projects/urllib3/demo.py", line 13, in main
    await inner()
Exception
 ✘  graingert@conscientious  ~/projects/urllib3   py3-12-debug ± vim demo.py 
 graingert@conscientious  ~/projects/urllib3   py3-12-debug ± ./.nox/test-3-12/bin/python -m demo
good

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions