summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-02-02 17:36:59 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-02-02 17:36:59 (GMT)
commit29ae7633e0e41d65e188c522248dcb620b055efc (patch)
tree5abb7756647b60de3f347437d87c77ba0b8d3e69 /Lib
parentc658d85487142099c1abe8e916c9864f7fc7b7a4 (diff)
parent5d44c08f1c18583d568283170454bab0c11f8257 (diff)
downloadcpython-29ae7633e0e41d65e188c522248dcb620b055efc.zip
cpython-29ae7633e0e41d65e188c522248dcb620b055efc.tar.gz
cpython-29ae7633e0e41d65e188c522248dcb620b055efc.tar.bz2
Merge 3.4 (asyncio)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/test_utils.py4
-rw-r--r--Lib/asyncio/unix_events.py12
-rw-r--r--Lib/asyncio/windows_events.py11
3 files changed, 23 insertions, 4 deletions
diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py
index 6eedc58..8cee95b 100644
--- a/Lib/asyncio/test_utils.py
+++ b/Lib/asyncio/test_utils.py
@@ -416,6 +416,10 @@ class TestCase(unittest.TestCase):
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
index 1fc39ab..75e7c9c 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -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
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
index c4bffc4..f311e46 100644
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -373,10 +373,17 @@ class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
**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