Skip to content

Commit 973fa0e

Browse files
committed
serial-console: decode binary WebSocket frames before printing
websocket-client delivers binary frames as Python bytes objects. Passing bytes directly to PC.print() causes print() to render them as raw repr strings (e.g. b'\r\r\n', b'login: ') instead of decoded text, which corrupts the serial console output in WSL and other non-Windows environments. Fix this by decoding bytes to str with UTF-8 (replacing invalid sequences) in on_message() before calling PC.print(). Fixes: Azure/azure-cli#33164 Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com> Signed-off-by: GitHub Copilot <copilot@github.com>
1 parent 0f3c8a9 commit 973fa0e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • src/serial-console/azext_serialconsole

src/serial-console/azext_serialconsole/custom.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ def on_message(_, message):
438438
GV.loading = False
439439
PC.clear_screen()
440440
else:
441+
if isinstance(message, bytes):
442+
message = message.decode('utf-8', errors='replace')
441443
PC.print(message)
442444

443445
def on_error(*_):

0 commit comments

Comments
 (0)