2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-26 11:30:23 +00:00

Fix tlvdata handling of unicode input

Unicode input is normalized to bytes.  Also have to handle python3
not having 'unicode', do a quick change to support that in both.
This commit is contained in:
Jarrod Johnson 2018-06-21 14:29:54 -04:00
parent baef8c2c42
commit d34e65f9b7

View File

@ -20,6 +20,11 @@ from datetime import datetime
import json
import struct
try:
unicode
except NameError:
unicode = str
def decodestr(value):
ret = None
try:
@ -54,7 +59,11 @@ def _unicode_list(currlist):
def send(handle, data):
if isinstance(data, str):
if isinstance(data, str) or isinstance(data, unicode):
try:
data = data.encode('utf-8')
except AttributeError:
pass
# plain text, e.g. console data
tl = len(data)
if tl == 0: