[msgpack][JIRA] Commented: (MSGPACK-15) Lists turn into tuples when packing, then unpacking in Python (2.6)

18 views
Skip to first unread message

EG (JIRA)

unread,
Mar 5, 2013, 3:49:11 PM3/5/13
to msgpa...@googlegroups.com

[ http://jira.msgpack.org/browse/MSGPACK-15?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=10510#comment-10510 ]

EG commented on MSGPACK-15:
---------------------------

Hi Naoki,

How would msgpack pack and unpack a dictionary containing a mix of tuples and lists? Your solution does not work for something like this:
msgpack.unpackb(msgpack.packb({'field1': (0, 123), 'field2': ['a', 'b', 'c']}))

No matter what you set use_list to, one of the fields will get mangled.





> Lists turn into tuples when packing, then unpacking in Python (2.6)
> -------------------------------------------------------------------
>
> Key: MSGPACK-15
> URL: http://jira.msgpack.org/browse/MSGPACK-15
> Project: MessagePack
> Issue Type: Bug
> Components: Specification
> Environment: Tested on Linux (RedHat) and Mac OSX using Python 2.6.1.
> Reporter: Justin Patrin
> Assignee: FURUHASHI Sadayuki
> Labels: Python
>
> Running the examples in the Python QuickStart page (and in my own tests) lists which are encoded then decoded come back as tuples.
> In [5]: import msgpack
> In [6]: serialized = msgpack.packb([1,2,3])
> In [7]: print msgpack.unpackb(serialized)
> (1, 2, 3)
> This is not correct as tuples are immutable while lists are mutable (among other differences). Both should be encoded and decoded as their own types, not as the same type.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


INADA Naoki (JIRA)

unread,
Mar 5, 2013, 6:31:11 PM3/5/13
to msgpa...@googlegroups.com

[ http://jira.msgpack.org/browse/MSGPACK-15?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=10511#comment-10511 ]

INADA Naoki commented on MSGPACK-15:
------------------------------------

Yes, and it's not a bug. JSON has same issue.
Adding custom type to msgpack is discussed in https://github.com/msgpack/msgpack/issues/128
Reply all
Reply to author
Forward
0 new messages