python / python/cpython

`asyncio.Timeout.__aexit__` does not handle `BaseExceptionGroup`

Offen
#137,549 2 Kommentare 0 Reaktionen 2 zugewiesene Personen Auf GitHub ansehen

@gunyu1019 arbeitet bereits daran.

Seit 15.8.2025.

stdlib topic-asyncio type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Bug report

Bug description:

There may be a good reason for this I am not seeing, but in the asyncio.Timeout.__aexit__ handler, the exception group handling seems too narrow:

https://github.com/python/cpython/blob/9743d069bd53e9d3a8f09df899ec1c906a79da24/Lib/asyncio/timeouts.py#L113-L119

Given exc_val itself can be a BaseException and _insert_timeout_error takes a BaseException as an argument, I fail to see a reason not to check for superclass BaseExceptionGroup instead.

https://github.com/python/cpython/blob/9743d069bd53e9d3a8f09df899ec1c906a79da24/Lib/asyncio/timeouts.py#L133

This no longer impacts me as I implemented what I was aiming for in a better way, but it still looks like a bug. Is it?

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs
  • gh-137797

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.