diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2005-12-04 19:11:17 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2005-12-04 19:11:17 (GMT) |
commit | bdb3901001fbf8a4cb68da75cd05ad12f79efd03 (patch) | |
tree | 1f75e139974d0f0b2c8622ab227ef2851e8a485d | |
parent | 47a39b011262be0767165a0b4c1979f3975ef5d8 (diff) | |
download | cpython-bdb3901001fbf8a4cb68da75cd05ad12f79efd03.zip cpython-bdb3901001fbf8a4cb68da75cd05ad12f79efd03.tar.gz cpython-bdb3901001fbf8a4cb68da75cd05ad12f79efd03.tar.bz2 |
[Bug #1164912] Ensure Datetime wrapper class .value attribute is an 8-bit string, not a Unicode string
-rw-r--r-- | Lib/test/test_xmlrpc.py | 10 | ||||
-rw-r--r-- | Lib/xmlrpclib.py | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py index ed4c6d1..0ef91dc 100644 --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -76,6 +76,16 @@ class XMLRPCTestCase(unittest.TestCase): (newdt,), m = xmlrpclib.loads(s, use_datetime=0) self.assertEquals(newdt, xmlrpclib.DateTime('%sT11:41:23'%today)) + def test_bug_1164912 (self): + d = xmlrpclib.DateTime() + ((new_d,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((d,), + methodresponse=True)) + self.assert_(isinstance(new_d.value, str)) + + # Check that the output of dumps() is still an 8-bit string + s = xmlrpclib.dumps((new_d,), methodresponse=True) + self.assert_(isinstance(s, str)) + def test_dump_big_long(self): self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,)) diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py index 069ebcc..6fb6c68 100644 --- a/Lib/xmlrpclib.py +++ b/Lib/xmlrpclib.py @@ -388,6 +388,7 @@ class DateTime: return "<DateTime %s at %x>" % (repr(self.value), id(self)) def decode(self, data): + data = str(data) self.value = string.strip(data) def encode(self, out): |