mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Merge 3.6 (asyncio)
This commit is contained in:
commit
caae4dbbc6
2 changed files with 19 additions and 3 deletions
|
@ -234,6 +234,11 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
|
||||||
else:
|
else:
|
||||||
if sock is None:
|
if sock is None:
|
||||||
raise ValueError('no path and sock were specified')
|
raise ValueError('no path and sock were specified')
|
||||||
|
if (sock.family != socket.AF_UNIX or
|
||||||
|
sock.type != socket.SOCK_STREAM):
|
||||||
|
raise ValueError(
|
||||||
|
'A UNIX Domain Stream Socket was expected, got {!r}'
|
||||||
|
.format(sock))
|
||||||
sock.setblocking(False)
|
sock.setblocking(False)
|
||||||
|
|
||||||
transport, protocol = yield from self._create_connection_transport(
|
transport, protocol = yield from self._create_connection_transport(
|
||||||
|
@ -272,9 +277,11 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
'path was not specified, and no sock specified')
|
'path was not specified, and no sock specified')
|
||||||
|
|
||||||
if sock.family != socket.AF_UNIX:
|
if (sock.family != socket.AF_UNIX or
|
||||||
|
sock.type != socket.SOCK_STREAM):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
'A UNIX Domain Socket was expected, got {!r}'.format(sock))
|
'A UNIX Domain Stream Socket was expected, got {!r}'
|
||||||
|
.format(sock))
|
||||||
|
|
||||||
server = base_events.Server(self, [sock])
|
server = base_events.Server(self, [sock])
|
||||||
sock.listen(backlog)
|
sock.listen(backlog)
|
||||||
|
|
|
@ -273,7 +273,16 @@ class SelectorEventLoopUnixSocketTests(test_utils.TestCase):
|
||||||
coro = self.loop.create_unix_server(lambda: None, path=None,
|
coro = self.loop.create_unix_server(lambda: None, path=None,
|
||||||
sock=sock)
|
sock=sock)
|
||||||
with self.assertRaisesRegex(ValueError,
|
with self.assertRaisesRegex(ValueError,
|
||||||
'A UNIX Domain Socket was expected'):
|
'A UNIX Domain Stream.*was expected'):
|
||||||
|
self.loop.run_until_complete(coro)
|
||||||
|
|
||||||
|
def test_create_unix_connection_path_inetsock(self):
|
||||||
|
sock = socket.socket()
|
||||||
|
with sock:
|
||||||
|
coro = self.loop.create_unix_connection(lambda: None, path=None,
|
||||||
|
sock=sock)
|
||||||
|
with self.assertRaisesRegex(ValueError,
|
||||||
|
'A UNIX Domain Stream.*was expected'):
|
||||||
self.loop.run_until_complete(coro)
|
self.loop.run_until_complete(coro)
|
||||||
|
|
||||||
@mock.patch('asyncio.unix_events.socket')
|
@mock.patch('asyncio.unix_events.socket')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue