| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 97b817e commit 7b69069
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,26 +25,9 @@ Exceptions | |||
| 25 | 25 | when asyncio Tasks are cancelled. In almost all situations the | |
| 26 | 26 | exception must be re-raised. | |
| 27 | 27 | ||
| 28 | - .. important:: | ||
| 29 | - | ||
| 30 | - This exception is a subclass of :exc:`Exception`, so it can be | ||
| 31 | - accidentally suppressed by an overly broad ``try..except`` block:: | ||
| 32 | - | ||
| 33 | - try: | ||
| 34 | - await operation | ||
| 35 | - except Exception: | ||
| 36 | - # The cancellation is broken because the *except* block | ||
| 37 | - # suppresses the CancelledError exception. | ||
| 38 | - log.log('an error has occurred') | ||
| 39 | - | ||
| 40 | - Instead, the following pattern should be used:: | ||
| 28 | + .. versionchanged:: 3.8 | ||
| 41 | 29 | ||
| 42 | - try: | ||
| 43 | - await operation | ||
| 44 | - except asyncio.CancelledError: | ||
| 45 | - raise | ||
| 46 | - except Exception: | ||
| 47 | - log.log('an error has occurred') | ||
| 30 | + :exc:`CancelledError` is now a subclass of :class:`BaseException`. | ||
| 48 | 31 | ||
| 49 | 32 | ||
| 50 | 33 | .. exception:: InvalidStateError | |
| Back | FazBrowse Home | New Git URL |
0 commit comments