details:   https://code.tryton.org/tryton/commit/0a0f4db765fb
branch:    default
user:      Nicolas Évrard <[email protected]>
date:      Wed Nov 26 21:50:01 2025 +0100
description:
        Register a MappingProxyType marshalling function for both JSON-RPC and 
XML-RPC

        Closes #14387
diffstat:

 trytond/trytond/protocols/jsonrpc.py |  2 ++
 trytond/trytond/protocols/xmlrpc.py  |  2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diffs (38 lines):

diff -r b6e96adbb37d -r 0a0f4db765fb trytond/trytond/protocols/jsonrpc.py
--- a/trytond/trytond/protocols/jsonrpc.py      Tue Nov 11 12:50:36 2025 +0100
+++ b/trytond/trytond/protocols/jsonrpc.py      Wed Nov 26 21:50:01 2025 +0100
@@ -5,6 +5,7 @@
 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 @@
         '__class__': 'timedelta',
         'seconds': o.total_seconds(),
         })
+JSONEncoder.register(MappingProxyType, dict)
 
 
 def _bytes_encoder(o):
diff -r b6e96adbb37d -r 0a0f4db765fb trytond/trytond/protocols/xmlrpc.py
--- a/trytond/trytond/protocols/xmlrpc.py       Tue Nov 11 12:50:36 2025 +0100
+++ b/trytond/trytond/protocols/xmlrpc.py       Wed Nov 26 21:50:01 2025 +0100
@@ -6,6 +6,7 @@
 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 @@
 
 client.Marshaller.dispatch[dict] = dump_struct
 client.Marshaller.dispatch[ImmutableDict] = dump_struct
+client.Marshaller.dispatch[MappingProxyType] = dump_struct
 
 
 class XMLRPCDecoder(object):

Reply via email to