Workaround CPython bug #23353 · python/asyncio@aeb1824 · GitHub
Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Commit aeb1824

Browse files
committed
Workaround CPython bug #23353
Don't use yield/yield-from in an except block of a generator. Store the exception and handle it outside the except block.
1 parent eec5196 commit aeb1824

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

asyncio/test_utils.py

Lines changed: 4 additions & 0 deletions

asyncio/unix_events.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,18 @@ def _make_subprocess_transport(self, protocol, args, shell,
186186
self._child_watcher_callback, transp)
187187
try:
188188
yield from waiter
189-
except:
189+
except Exception as exc:
190+
# Workaround CPython bug #23353: using yield/yield-from in an
191+
# except block of a generator doesn't clear properly
192+
# sys.exc_info()
193+
err = exc
194+
else:
195+
err = None
196+
197+
if err is not None:
190198
transp.close()
191199
yield from transp._wait()
192-
raise
200+
raise err
193201

194202
return transp
195203

asyncio/windows_events.py

Lines changed: 9 additions & 2 deletions

0 commit comments

Comments
 (0)