Stream serialization exmple doesn't work with Python 3.5.1
utgarda opened this issue · 3 comments
utgarda commented
[etsvigun@Jotunheim ~]$ python
Python 3.5.1 (default, Dec 7 2015, 12:58:09)
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import umsgpack
>>> f = open('test.bin', 'w')
>>> umsgpack.pack({u"compact": True, u"schema":0}, f)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/site-packages/umsgpack.py", line 428, in _pack3
_pack_map(obj, fp)
File "/usr/lib/python3.5/site-packages/umsgpack.py", line 323, in _pack_map
fp.write(struct.pack("B", 0x80 | len(obj)))
TypeError: write() argument must be str, not bytes
vsergeev commented
Thanks for bringing this to my attention. I'll fix the documentation.
The file should be opened with binary mode:
>>> import umsgpack
>>> f = open('test.bin', 'wb')
>>> umsgpack.pack({u"compact": True, u"schema":0}, f)
>>>