From f04f2fd41646edf10e99d8dd45487614cf5e54b4 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 3 Aug 2018 14:37:57 -0400 Subject: [PATCH] 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 --- pyghmi/ipmi/console.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyghmi/ipmi/console.py b/pyghmi/ipmi/console.py index 06e7194e..727420fe 100644 --- a/pyghmi/ipmi/console.py +++ b/pyghmi/ipmi/console.py @@ -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: