Register a MappingProxyType marshalling function for both JSON-RPC and XML-RPC

Closes #14387
This commit is contained in:
Nicolas Évrard
2025-11-26 21:50:01 +01:00
parent c92dd960a3
commit 3ed88c83c5
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -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):
+2
View File
@@ -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):