2
0
mirror of https://opendev.org/x/pyghmi synced 2025-08-24 03:50:20 +00:00

Fix console input with unicode

If unicode data comes in, coerce it to utf8 so it can be concatenated
to a bytearray.

Change-Id: Idfefbd8d89a817b3c93daa295c76ab829d2be8d3
This commit is contained in:
Jarrod Johnson
2018-08-03 14:37:57 -04:00
parent 5b4dc292a6
commit f04f2fd416

View File

@@ -258,7 +258,11 @@ class Console(object):
breakbyte = 0
if sendbreak:
breakbyte = 0b10000
payload = bytearray((self.myseq, 0, 0, breakbyte)) + output
try:
payload = bytearray((self.myseq, 0, 0, breakbyte)) + output
except TypeError: # bytearray hits unicode...
payload = bytearray((self.myseq, 0, 0, breakbyte
)) + output.encode('utf8')
self.lasttextsize = len(output)
needskeepalive = False
if self.lasttextsize == 0: