This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Recipients acdha, ezio.melotti,, pitrou, r.david.murray, rhettinger, serhiy.storchaka
Date 2014-02-26.16:43:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The JSON implementation uses these tests to determine how to serialize a Python object:

    isinstance(o, (list, tuple))
    isinstance(o, dict)

So any subclasses of list and tuple are serialized as a list, and any subclass of dict is serialized as an object. For example:

    >>> json.dumps(collections.defaultdict())
    >>> json.dumps(collections.OrderedDict())
    >>> json.dumps(collections.namedtuple('mytuple', ())())

When deserialized, you'll get back a plain dictionary or list, so there's no round-trip property here.

The tests could perhaps be changed to:


I'm not a JSON expert, so I have no informed opinion on whether this is a good idea or not, but in any case, this change wouldn't help with deques, as a deque is not a Sequence. That's because deques don't have an index method (see issue10059 and issue12543).
Date User Action Args
2014-02-26 16:43:50gdr@garethrees.orgsetrecipients: +, rhettinger, pitrou, ezio.melotti, r.david.murray, serhiy.storchaka, acdha
2014-02-26 16:43:49gdr@garethrees.orgsetmessageid: <>
2014-02-26 16:43:49gdr@garethrees.orglinkissue20774 messages
2014-02-26 16:43:49gdr@garethrees.orgcreate