mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Don't use yield/yield-from in an except block of a generator. Store the exception and handle it outside the except block.
This commit is contained in:
parent
7a66fc22ad
commit
5d44c08f1c
3 changed files with 23 additions and 4 deletions
|
@ -186,10 +186,18 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
|
|||
self._child_watcher_callback, transp)
|
||||
try:
|
||||
yield from waiter
|
||||
except:
|
||||
except Exception as exc:
|
||||
# Workaround CPython bug #23353: using yield/yield-from in an
|
||||
# except block of a generator doesn't clear properly
|
||||
# sys.exc_info()
|
||||
err = exc
|
||||
else:
|
||||
err = None
|
||||
|
||||
if err is not None:
|
||||
transp.close()
|
||||
yield from transp._wait()
|
||||
raise
|
||||
raise err
|
||||
|
||||
return transp
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue