Message212215
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 |
|
Date |
User |
Action |
Args |
2014-02-25 21:15:50 | acdha | set | recipients:
+ acdha |
2014-02-25 21:15:50 | acdha | set | messageid: <1393362950.58.0.308283739635.issue20774@psf.upfronthosting.co.za> |
2014-02-25 21:15:50 | acdha | link | issue20774 messages |
2014-02-25 21:15:50 | acdha | create | |
|