Last active
November 8, 2025 14:25
-
-
Save njsmith/ac696325c7d59bb7c5f1c7bb29b090df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async def f(): | |
| return ValueError() | |
| async def g(): | |
| try: | |
| raise KeyError | |
| except: | |
| value_error = await f() | |
| # This prints: KeyError() in CPython 3.5, 3.6, current master | |
| # Apparently returning an exception object from an async function triggers | |
| # implicit exception chaining?! | |
| print(repr(value_error.__context__)) | |
| try: | |
| g().send(None) | |
| except StopIteration: | |
| pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment