From 81d685b07d3518ae132bd85186b704302df4f53f Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Feb 21 2020 08:44:46 +0000 Subject: xmlrpcplus: use parent Marshaller's nil implementation We can enable the None -> "nil" behavior when we instantiate our Marshaller. RHEL 5 and newer supports allow_none here. This allows us to drop the dump_nil code from our custom Marshaller and rely directly on the parent class's method instead. --- diff --git a/koji/xmlrpcplus.py b/koji/xmlrpcplus.py index de2f54f..e24d415 100644 --- a/koji/xmlrpcplus.py +++ b/koji/xmlrpcplus.py @@ -50,11 +50,6 @@ class ExtendedMarshaller(xmlrpc_client.Marshaller): return xmlrpc_client.Marshaller.dump_int(self, value, write) dispatch[int] = dump_int - # we always want to allow None - def dump_nil(self, value, write): - write("") - dispatch[type(None)] = dump_nil - if six.PY2: ExtendedMarshaller.dispatch[long] = ExtendedMarshaller.dump_int @@ -82,9 +77,9 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None, encoding = "utf-8" if marshaller is not None: - m = marshaller(encoding) + m = marshaller(encoding, allow_none=True) else: - m = ExtendedMarshaller(encoding) + m = ExtendedMarshaller(encoding, allow_none=True) data = m.dumps(params)