narrow bare except around _try_inline_read to Exception in five readers#3639
Open
HrachShah wants to merge 1 commit into
Open
narrow bare except around _try_inline_read to Exception in five readers#3639HrachShah wants to merge 1 commit into
HrachShah wants to merge 1 commit into
Conversation
The bare 'except:' in read_until_regex, read_until, read_bytes, read_into, and read_until_close was wrapping self._try_inline_read() so the caller could install a done_callback that pulls .exception() off the future and silence the 'Future exception was never retrieved' warning before re-raising. That bare except also caught BaseException, so a KeyboardInterrupt, SystemExit, asyncio.CancelledError, MemoryError, or RecursionError raised inside _try_inline_read() (or any of the per-call setup just above the try block, like re.compile()) was intercepted, queued the done_callback, then re-raised — meaning Ctrl-C during a network read briefly invoked a useless future.add_done_callback on its way out instead of cancelling the awaitable immediately. Narrowing to 'except Exception:' preserves the documented intent (silence the unexamined-future warning for ordinary failures like UnsatisfiableReadError, StreamClosedError, OSError, ValueError from re.compile, and LookupError from a bad regex) while letting real shutdown signals propagate straight through to the awaiting coroutine.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bare 'except:' in read_until_regex, read_until, read_bytes, read_into, and read_until_close was wrapping self._try_inline_read() so the caller could install a done_callback that pulls .exception() off the future and silence the 'Future exception was never retrieved' warning before re-raising.
That bare except also caught BaseException, so a KeyboardInterrupt, SystemExit, asyncio.CancelledError, MemoryError, or RecursionError raised inside _try_inline_read() (or any of the per-call setup just above the try block, like re.compile()) was intercepted, queued the done_callback, then re-raised — meaning Ctrl-C during a network read briefly invoked a useless future.add_done_callback on its way out instead of cancelling the awaitable immediately.
Narrowing to 'except Exception:' preserves the documented intent (silence the unexamined-future warning for ordinary failures like UnsatisfiableReadError, StreamClosedError, OSError, ValueError from re.compile, and LookupError from a bad regex) while letting real shutdown signals propagate straight through to the awaiting coroutine.
All 142 iostream tests pass (61 skipped, no new failures).