Skip to content

Commit ad88546

Browse files
committed
Fix create_server to accept only proto and sock args
1 parent 2ad9239 commit ad88546

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tests/test_tcp.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ async def start_server_sock():
127127
self.loop.run_until_complete(start_server_sock())
128128
self.assertEqual(CNT, TOTAL_CNT)
129129

130+
def test_create_server_2(self):
131+
with self.assertRaisesRegex(ValueError, 'nor sock were specified'):
132+
self.loop.run_until_complete(self.loop.create_server(object))
133+
130134
def test_create_connection_1(self):
131135
CNT = 0
132136
TOTAL_CNT = 100

uvloop/loop.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ cdef class Loop:
993993
return await self._getnameinfo(ai.ai_addr, flags)
994994

995995
@aio_coroutine
996-
async def create_server(self, protocol_factory, host, port,
996+
async def create_server(self, protocol_factory, host=None, port=None,
997997
*,
998998
int family=uv.AF_UNSPEC,
999999
int flags=uv.AI_PASSIVE,
@@ -1053,6 +1053,8 @@ cdef class Loop:
10531053
if not completed:
10541054
server.close()
10551055
else:
1056+
if sock is None:
1057+
raise ValueError('Neither host/port nor sock were specified')
10561058
tcp = TCPServer.new(self, protocol_factory, server, ssl)
10571059
fileno = os_dup(sock.fileno())
10581060
try:

0 commit comments

Comments
 (0)