Skip to content

Commit 1b901de

Browse files
prevent crash when client sends empty event
1 parent f147604 commit 1b901de

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/socketio/async_namespace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def trigger_event(self, event, *args):
2929
3030
Note: this method is a coroutine.
3131
"""
32-
handler_name = 'on_' + event
32+
handler_name = 'on_' + (event or '')
3333
if hasattr(self, handler_name):
3434
handler = getattr(self, handler_name)
3535
if asyncio.iscoroutinefunction(handler) is True:
@@ -194,7 +194,7 @@ async def trigger_event(self, event, *args):
194194
195195
Note: this method is a coroutine.
196196
"""
197-
handler_name = 'on_' + event
197+
handler_name = 'on_' + (event or '')
198198
if hasattr(self, handler_name):
199199
handler = getattr(self, handler_name)
200200
if asyncio.iscoroutinefunction(handler) is True:

src/socketio/namespace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def trigger_event(self, event, *args):
2121
method can be overridden if special dispatching rules are needed, or if
2222
having a single method that catches all events is desired.
2323
"""
24-
handler_name = 'on_' + event
24+
handler_name = 'on_' + (event or '')
2525
if hasattr(self, handler_name):
2626
return getattr(self, handler_name)(*args)
2727

@@ -152,7 +152,7 @@ def trigger_event(self, event, *args):
152152
method can be overridden if special dispatching rules are needed, or if
153153
having a single method that catches all events is desired.
154154
"""
155-
handler_name = 'on_' + event
155+
handler_name = 'on_' + (event or '')
156156
if hasattr(self, handler_name):
157157
return getattr(self, handler_name)(*args)
158158

0 commit comments

Comments
 (0)