[Ironpython-users] b64encode(bz2.compress()) throws exception.
Hernán Foffani
hfoffani at gmail.com
Wed Aug 27 16:53:22 CEST 2014
Hi,
This works on CPython but on IronPython throws an exception in base64.b64encode.
from __future__ import print_function
import cPickle
import bz2
import base64
def serializa(o):
s1 = cPickle.dumps(o)
s2 = bz2.compress(s1)
s = base64.b64encode(s2)
return s
def deserializa(s):
o = cPickle.loads(bz2.decompress(base64.b64decode(s)))
return o
def procesa():
l1 = [23,4,303,None,'.',32023.03,0]
l2 = deserializa(serializa(l1))
print(l1, l2)
procesa()
C:\> ipy.exe x.py
Traceback (most recent call last):
File "x.py", line 23, in <module>
File "x.py", line 20, in procesa
File "x.py", line 10, in serializa
File "C:\Program Files\IronPython 2.7\Lib\base64.py", line 53, in b64encode
TypeError: expected str, got bytes
Pythons:
Python 2.7.8 (default, Aug 24 2014, 21:26:19)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information
IronPython 2.7.3 (2.7.0.40) on .NET 4.0.30319.18444 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
Regards,
Hernán.
More information about the Ironpython-users
mailing list