File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -448,9 +448,12 @@ async def on_message_for_websocket(
448448 shutdown = True
449449 elif msg :
450450 _LOGGER .info ("PREPARING %s" , message_context .offset )
451- # We know the AMQPMessage (as a string will start "b'" and end "'"
452- # message_string = msg.decode("utf-8")
453- message_string = eval (msg ).decode ("utf-8" ) # pylint: disable=eval-used
451+ # The msg (an AMQPMessage) cannot be decoded directly.
452+ # Instead, if we want to manipulate it (as a string)
453+ # we must str() it and eval() it! It's the easiest way because this way
454+ # it becomes a string representation of a bytestring, not a bytestring.
455+ # Once we eval() it it becomes a bytestring and we can decode it.
456+ message_string = eval (str (msg )).decode ("utf-8" ) # pylint: disable=eval-used
454457 _LOGGER .info ("TRIMMED %s" , message_context .offset )
455458 if message_string [0 ] == "{" :
456459 _LOGGER .info ("IS JSON %s" , message_context .offset )
You can’t perform that action at this time.
0 commit comments