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.
This commit is contained in:
Ken Dreyer 2017-12-13 16:03:32 -07:00 committed by Tomas Kopecek
parent aa35b84c8c
commit 81d685b07d

View file

@ -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("<value><nil/></value>")
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)