From e2242ce40e65c682e031d245db50fdd7956c3b2d Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 15 Feb 2020 07:12:47 +0800 Subject: [PATCH] Fix Server and AsyncServer when emitting no data (#420) --- socketio/asyncio_server.py | 4 +++- socketio/server.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/socketio/asyncio_server.py b/socketio/asyncio_server.py index 0115a47..9b41a69 100644 --- a/socketio/asyncio_server.py +++ b/socketio/asyncio_server.py @@ -362,8 +362,10 @@ class AsyncServer(server.Server): # as a single argument if isinstance(data, tuple): data = list(data) - else: + elif data is not None: data = [data] + else: + data = [] await self._send_packet(sid, packet.Packet( packet.EVENT, namespace=namespace, data=[event] + data, id=id, binary=None)) diff --git a/socketio/server.py b/socketio/server.py index 8848de7..2444526 100644 --- a/socketio/server.py +++ b/socketio/server.py @@ -573,8 +573,10 @@ class Server(object): # as a single argument if isinstance(data, tuple): data = list(data) - else: + elif data is not None: data = [data] + else: + data = [] self._send_packet(sid, packet.Packet(packet.EVENT, namespace=namespace, data=[event] + data, id=id, binary=binary))