Commit a9a9a0b5 authored by Stefan H. Holek's avatar Stefan H. Holek

DateTime marshalling addendum:

Fixed edge case of attribute name ''.
parent 8510adec
......@@ -191,6 +191,19 @@ class XMLRPCResponseTests(unittest.TestCase):
response.setBody(body)
self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, faux._body)
def test_emptystringattribute(self):
# Test an edge case: attribute name '' is possible,
# at least in theory.
import xmlrpclib
body = FauxInstance(_secret='abc')
setattr(body, '', True)
faux = FauxResponse()
response = self._makeOne(faux)
response.setBody(body)
data, method = xmlrpclib.loads(faux._body)
data = data[0]
self.assertEqual(data, {'': True})
def test_suite():
return unittest.TestSuite((unittest.makeSuite(XMLRPCResponseTests),))
......
......@@ -43,7 +43,8 @@ def dump_instance(self, value, write):
# We want to avoid disclosing private attributes.
# Private attributes are by convention named with
# a leading underscore character.
value = dict([(k, v) for (k, v) in value.__dict__.items() if k[0] != '_'])
value = dict([(k, v) for (k, v) in value.__dict__.items()
if k[:1] != '_'])
self.dump_struct(value, write)
xmlrpclib.Marshaller.dispatch[types.InstanceType] = dump_instance
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment