New submission from Chris Adams: Currently the stdlib json module requires a custom serializer to avoid throwing a TypeError on collections.deque instances:
Python 3.3.4 (default, Feb 12 2014, 09:35:54) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from collections import deque >>> import json >>> d = deque(range(0, 10)) >>> json.dumps(d) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/json/__init__.py", line 233, in dumps return _default_encoder.encode(obj) File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/json/encoder.py", line 191, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/json/encoder.py", line 249, in iterencode return _iterencode(o, 0) File "/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/lib/python3.3/json/encoder.py", line 173, in default raise TypeError(repr(o) + " is not JSON serializable") TypeError: deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) is not JSON serializable ---------- messages: 212215 nosy: acdha priority: normal severity: normal status: open title: collections.deque should ship with a stdlib json serializer versions: Python 2.7, Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20774> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com