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.

Author Michael Smith2
Recipients Michael Smith2
Date 2018-10-01.01:56:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1538358992.7.0.545547206417.issue34858@psf.upfronthosting.co.za>
In-reply-to
Content
If a mappingproxy object is a read-only proxy to a mapping, would it make sense for them to JSON serialize just like the mapping they come from? Currently, json.dumps throws the "I don't know how to serialize this" error:

$ python -c 'import json
> import types
> json.dumps(types.MappingProxyType({}))'
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/usr/lib64/python3.6/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib64/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib64/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib64/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'mappingproxy' is not JSON serializable
History
Date User Action Args
2018-10-01 01:56:32Michael Smith2setrecipients: + Michael Smith2
2018-10-01 01:56:32Michael Smith2setmessageid: <1538358992.7.0.545547206417.issue34858@psf.upfronthosting.co.za>
2018-10-01 01:56:32Michael Smith2linkissue34858 messages
2018-10-01 01:56:31Michael Smith2create