Hi All,
I ran into an issue bytearray with encoding. The scenario I am using it is with 
read/writing data over the serial com port. I notice in CPython 2.7.8 the 
following works
>>> bytearray('Michael Gilfix was here\n')bytearray(b'Michael Gilfix was 
>>> here\n')

In IronPython 2.7.5 beta I get the following>>> b = bytearray('Michael Gilfix 
was here\n')Traceback (most recent call last):  File "<stdin>", line 1, in 
<module>TypeError: unicode argument without an encoding
I can get it to work if I do the followingb = bytearray(b'Michael Gilfix was 
here\n')
does the bytearray in CPython do an implicit encoding if not specific to 
binary? 

I am trying to use hex with bytearray but I see issues with that as well with 
encoding. Here is an example
CPython 2.7.8>>> hex_string = "deadbeef">>> hex_data = 
hex_string.decode("hex")>>> hex_data'\xde\xad\xbe\xef'>>> 
bytearray(hex_data)bytearray(b'\xde\xad\xbe\xef')
IronPython 2.7.5 Beta >>> hex_string = "deadbeef">>> hex_data = 
hex_string.decode("hex")>>> hex_datau'\xde\xad\xbe\xef'>>> 
bytearray(hex_data)Traceback (most recent call last):  File "<stdin>", line 1, 
in <module>TypeError: unicode argument without an encoding
>>> bytearray(hex_data, 'hex')bytearray(b'deadbeef')

Thanks
Danny                                     
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
https://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to