blob: c392b6a55774e444c9afc0cc487451414f055424 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
if bytes is str:
def bytes2str(bstr):
assert isinstance(bstr, bytes)
return bstr
def str2bytes(sstr):
assert isinstance(sstr, str)
return sstr
else:
def bytes2str(bstr):
assert isinstance(bstr, bytes)
return bstr.decode("iso-8859-1") # always successful
def str2bytes(sstr):
assert isinstance(sstr, str)
return sstr.encode("iso-8859-1") # might fail, but spec says it doesn't
|