mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-26 03:19:48 +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:
parent
baef8c2c42
commit
d34e65f9b7
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user