blob: b2f47dc9f1f51af36f8d405947064896d20ffefd [file] [log] [blame]
import sys
if sys.version_info[0] == 2:
from cStringIO import StringIO as BufferIO
def binary_to_str(bin_val):
return bin_val
def str_to_binary(str_val):
return str_val
else:
from io import BytesIO as BufferIO
def binary_to_str(bin_val):
try:
return bin_val.decode('utf8')
except:
return bin_val
def str_to_binary(str_val):
try:
return bytearray(str_val, 'utf8')
except:
return str_val