Issue 2979: use_builtin_types in xmlrpc.server (original) (raw)
It seems strange to me that xmlrpclib.ServerProxy has a use_datetime argument, but not SimpleXMLRPCServer or CGIXMLRPCRequestHandler.
I'm hereby submitting a patch to fix this.
Sorry for the shaky testing (I only really test SimpleXMLRPCDispatcher), but trying to test at the SimpleXMLRPCServer level using the current http_server() scheme quickly became dirty, so I backed off.
2096158376e5 broke test_xmlrpc:
"""
ERROR: test_datetime_before_1900 (test.test_xmlrpc.XMLRPCTestCase)
Traceback (most recent call last): File "/home/cf/python/cpython/Lib/test/test_xmlrpc.py", line 62, in test_datetime_before_1900 (newdt,), m = xmlrpclib.loads(s, use_datetime=1) File "/home/cf/python/cpython/Lib/xmlrpc/client.py", line 969, in loads p.feed(data) File "/home/cf/python/cpython/Lib/xmlrpc/client.py", line 430, in feed self._parser.Parse(data, 0) File "/home/cf/python/cpython/Lib/xmlrpc/client.py", line 662, in end return f(self, "".join(self._data)) File "/home/cf/python/cpython/Lib/xmlrpc/client.py", line 745, in end_dateTime value = _datetime_type(data) File "/home/cf/python/cpython/Lib/xmlrpc/client.py", line 359, in _datetime_type return datetime.strptime(data, "%Y%m%dT%H:%M:%S") File "/home/cf/python/cpython/Lib/_strptime.py", line 488, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "/home/cf/python/cpython/Lib/_strptime.py", line 337, in _strptime (data_string, format)) ValueError: time data '10210T11:41:23' does not match format '%Y%m%dT%H:%M:%S'
"""
That's because datetime.strptime() expects a year ("%Y") on exactly 4 digits: """ #XXX: Does 'Y' need to worry about having less or more than # 4 digits? 'Y': r"(?P\d\d\d\d)", """