cpython: 44e77709daa4 (original) (raw)
Mercurial > cpython
changeset 93486:44e77709daa4
- Issue #22841: Reject coroutines in asyncio add_signal_handler(). Patch by Ludovic.Gasc. [#22841]
Guido van Rossum guido@python.org | |
---|---|
date | Fri, 14 Nov 2014 11:48:37 -0800 |
parents | 19b2c54e5f09(current diff)d244e1770f1b(diff) |
children | 97dc64adb6fe |
files | Lib/asyncio/unix_events.py Lib/test/test_asyncio/test_unix_events.py Misc/NEWS |
diffstat | 3 files changed, 18 insertions(+), 0 deletions(-)[+] [-] Lib/asyncio/unix_events.py 3 Lib/test/test_asyncio/test_unix_events.py 12 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -13,6 +13,7 @@ import threading from . import base_events from . import base_subprocess from . import constants +from . import coroutines from . import events from . import selector_events from . import selectors @@ -66,6 +67,8 @@ class _UnixSelectorEventLoop(selector_ev Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. """
if coroutines.iscoroutinefunction(callback):[](#l1.15)
raise TypeError("coroutines cannot be used with call_soon()")[](#l1.16) self._check_signal(sig)[](#l1.17) try:[](#l1.18) # set_wakeup_fd() raises ValueError if this is not the[](#l1.19)
--- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -64,6 +64,18 @@ class SelectorEventLoopSignalTests(test_ signal.SIGINT, lambda: True) @mock.patch('asyncio.unix_events.signal')
@asyncio.coroutine[](#l2.9)
def simple_coroutine():[](#l2.10)
yield from [][](#l2.11)
self.assertRaises([](#l2.13)
TypeError,[](#l2.14)
self.loop.add_signal_handler,[](#l2.15)
signal.SIGINT, simple_coroutine)[](#l2.16)
- @mock.patch('asyncio.unix_events.signal') def test_add_signal_handler(self, m_signal): m_signal.NSIG = signal.NSIG
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -183,6 +183,9 @@ Core and Builtins Library ------- +- Issue #22841: Reject coroutines in asyncio add_signal_handler().