[Ironpython-users] b64encode(bz2.compress()) throws exception.

Hernán Foffani hfoffani at gmail.com
Wed Aug 27 18:10:16 CEST 2014


Sorry, I meant the input of cPickle.loads()

El 27/08/2014, a las 18:02, Hernán Foffani <hfoffani at gmail.com> escribió:

> Thanks for the str() workaround; haven’t thought of it.
> Same thing with the output of b64decode.
> 
> 
> El 27/08/2014, a las 17:53, Pawel Jasinski <pawel.jasinski at gmail.com> escribió:
> 
>> BytesConversion on argument fixes it:
>> 
>>  public static object b2a_base64([BytesConversion]string data)
>> 
>> Short term workaround, try adding str() around an argument
>> 
>> 
>> On Wed, Aug 27, 2014 at 5:17 PM, Slide <slide.o.mix at gmail.com> wrote:
>> Can you file an issue on ironpython.codeplex.com?
>> 
>> 
>> On Wed, Aug 27, 2014 at 7:53 AM, Hernán Foffani <hfoffani at gmail.com> wrote:
>> 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.
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Ironpython-users mailing list
>> Ironpython-users at python.org
>> https://mail.python.org/mailman/listinfo/ironpython-users
>> 
>> 
>> 
>> -- 
>> Website: http://earl-of-code.com
>> 
>> _______________________________________________
>> Ironpython-users mailing list
>> Ironpython-users at python.org
>> https://mail.python.org/mailman/listinfo/ironpython-users
>> 
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20140827/1b0b1a28/attachment.html>


More information about the Ironpython-users mailing list