Skip to content

🤖 AsyncIOEventEmitter Emits Falsey Errors - #229

Merged
jfhbrook merged 1 commit into
jfhbrook:mainfrom
AlexXuz:fix-asyncio-exception-truthiness
Oct 31, 2026
Merged

jfhbrook merged 1 commit into
jfhbrook:mainfrom
AlexXuz:fix-asyncio-exception-truthiness

Conversation

@AlexXuz

@AlexXuz AlexXuz commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

What Is This?

Preserve asynchronous handler errors regardless of their truthiness by checking the None sentinel returned by Future.exception() directly.

Add regression tests for both coroutine handlers and returned futures, covering exception types whose __bool__ returns False or raises. The tests assert that the original exception object reaches the error listener.

Why Is This?

The asyncio completion callback currently uses if exc. An exception with __bool__ returning False is silently discarded instead of reaching the error listener. If __bool__ raises, the callback fails with that new error instead.

Using if exc is not None preserves the original exception object without evaluating its truth value. Successful and cancelled futures keep their existing behavior.

Anything We Need To Know?

AI coding assistants were used for this contribution, including the implementation and independent review. The commit subject and upcoming changelog entry use the required 🤖 marker. Added the public GitHub handle to CONTRIBUTORS.md without an email address.

Validation:

  • All four new regression cases fail on the original source.
  • Linux CPython 3.12.14 and 3.13.5: all 57 tests pass on each.
  • Black, isort, flake8, mypy (16 files), Pyright and project metadata validation pass.
  • An independent local 79-case matrix passed, covering synchronous/coroutine/Task/Future handlers, error listeners, success and cancellation. The unmodified baseline failed 36 affected cases.
  • Python 3.14, other operating systems, documentation builds and distribution builds were not tested locally.

Questions

  • Has the developer read DEVELOPMENT.md?
  • Have tests been updated accordingly?
  • Have AI assisted commits been marked with a 🤖 emoji?
  • Have AI assisted changes been marked with a 🤖 emoji in CHANGELOG.md?
  • Does the PR notify the use of AI coding assistants?
  • Is the developer's name in the CONTRIBUTORS.md file?

@jfhbrook
jfhbrook marked this pull request as ready for review October 30, 2026 19:43
@jfhbrook
jfhbrook force-pushed the fix-asyncio-exception-truthiness branch from a8c33bd to e897b3c Compare October 30, 2026 20:00
@jfhbrook jfhbrook changed the title 🤖 Preserve asynchronous handler errors regardless of truthiness 🤖 AsyncIOEventEmitter Emits Falsey Errors Oct 30, 2026
@jfhbrook
jfhbrook merged commit cb9be73 into jfhbrook:main Oct 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants