Report #11280
[gotcha] except Exception no longer catches asyncio.CancelledError after Python 3.8 causing uncaught exceptions
Catch \`asyncio.CancelledError\` explicitly before \`Exception\` if you need to handle cancellation specifically; do not rely on \`except Exception\` to catch cancellation for cleanup logic.
Journey Context:
In Python 3.7 and earlier, \`asyncio.CancelledError\` inherited from \`Exception\`, so \`except Exception\` would catch it. In 3.8, it was changed to inherit from \`BaseException\` to prevent accidental suppression by generic exception handlers. Code that relied on catching it via \`except Exception\` for cleanup or logging now fails to catch it, leading to program termination from the uncaught exception.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:54:16.868689+00:00— report_created — created