[Python-checkins] cpython (merge 3.4 -> default): Merge 3.4 (asyncio)
victor.stinner
python-checkins at python.org
Mon Feb 2 18:38:10 CET 2015
https://hg.python.org/cpython/rev/42b376c8cf60
changeset: 94465:42b376c8cf60
parent: 94463:0b3bc51341aa
parent: 94464:2cd6621a9fbc
user: Victor Stinner <victor.stinner at gmail.com>
date: Mon Feb 02 18:36:59 2015 +0100
summary:
Merge 3.4 (asyncio)
files:
Lib/asyncio/test_utils.py | 4 ++++
Lib/asyncio/unix_events.py | 12 ++++++++++--
Lib/asyncio/windows_events.py | 11 +++++++++--
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py
--- a/Lib/asyncio/test_utils.py
+++ b/Lib/asyncio/test_utils.py
@@ -416,6 +416,10 @@
def tearDown(self):
events.set_event_loop(None)
+ # Detect CPython bug #23353: ensure that yield/yield-from is not used
+ # in an except block of a generator
+ self.assertEqual(sys.exc_info(), (None, None, None))
+
@contextlib.contextmanager
def disable_logger():
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -186,10 +186,18 @@
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
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -373,10 +373,17 @@
**kwargs)
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
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list