Register a MappingProxyType marshalling function for both JSON-RPC and XML-RPC
Closes #14387
This commit is contained in:
@@ -5,6 +5,7 @@ import datetime
|
||||
import gzip
|
||||
import json
|
||||
from decimal import Decimal
|
||||
from types import MappingProxyType
|
||||
|
||||
from werkzeug.exceptions import (
|
||||
BadRequest, Conflict, Forbidden, HTTPException, InternalServerError,
|
||||
@@ -100,6 +101,7 @@ JSONEncoder.register(datetime.timedelta,
|
||||
'__class__': 'timedelta',
|
||||
'seconds': o.total_seconds(),
|
||||
})
|
||||
JSONEncoder.register(MappingProxyType, dict)
|
||||
|
||||
|
||||
def _bytes_encoder(o):
|
||||
|
||||
@@ -6,6 +6,7 @@ import logging
|
||||
import xmlrpc.client as client
|
||||
# convert decimal to float before marshalling:
|
||||
from decimal import Decimal
|
||||
from types import MappingProxyType
|
||||
|
||||
import defusedxml.xmlrpc
|
||||
from werkzeug.exceptions import (
|
||||
@@ -86,6 +87,7 @@ def dump_struct(self, value, write, escape=client.escape):
|
||||
|
||||
client.Marshaller.dispatch[dict] = dump_struct
|
||||
client.Marshaller.dispatch[ImmutableDict] = dump_struct
|
||||
client.Marshaller.dispatch[MappingProxyType] = dump_struct
|
||||
|
||||
|
||||
class XMLRPCDecoder(object):
|
||||
|
||||
Reference in New Issue
Block a user