changeset: 101221:0d015f6aba8b branch: 3.5 parent: 101217:194b356c84f5 user: Serhiy Storchaka date: Wed May 04 11:26:42 2016 +0300 files: Lib/test/test_xmlrpc.py Lib/xmlrpc/client.py Misc/NEWS description: Issue #26873: xmlrpc now raises ResponseError on unsupported type tags instead of silently return incorrect result. diff -r 194b356c84f5 -r 0d015f6aba8b Lib/test/test_xmlrpc.py --- a/Lib/test/test_xmlrpc.py Tue May 03 21:17:03 2016 +0300 +++ b/Lib/test/test_xmlrpc.py Wed May 04 11:26:42 2016 +0300 @@ -224,6 +224,20 @@ self.assertIs(type(newvalue), xmlrpclib.Binary) self.assertIsNone(m) + def test_loads_unsupported(self): + ResponseError = xmlrpclib.ResponseError + data = '' + self.assertRaises(ResponseError, xmlrpclib.loads, data) + data = ('' + '' + '') + self.assertRaises(ResponseError, xmlrpclib.loads, data) + data = ('' + 'a' + 'b' + '') + self.assertRaises(ResponseError, xmlrpclib.loads, data) + def test_get_host_info(self): # see bug #3613, this raised a TypeError transp = xmlrpc.client.Transport() diff -r 194b356c84f5 -r 0d015f6aba8b Lib/xmlrpc/client.py --- a/Lib/xmlrpc/client.py Tue May 03 21:17:03 2016 +0300 +++ b/Lib/xmlrpc/client.py Wed May 04 11:26:42 2016 +0300 @@ -640,6 +640,7 @@ self._stack = [] self._marks = [] self._data = [] + self._value = False self._methodname = None self._encoding = "utf-8" self.append = self._stack.append @@ -669,6 +670,8 @@ if tag == "array" or tag == "struct": self._marks.append(len(self._stack)) self._data = [] + if self._value and tag not in self.dispatch: + raise ResponseError("unknown tag %r" % tag) self._value = (tag == "value") def data(self, text): diff -r 194b356c84f5 -r 0d015f6aba8b Misc/NEWS --- a/Misc/NEWS Tue May 03 21:17:03 2016 +0300 +++ b/Misc/NEWS Wed May 04 11:26:42 2016 +0300 @@ -107,6 +107,9 @@ Library ------- +- Issue #26873: xmlrpc now raises ResponseError on unsupported type tags + instead of silently return incorrect result. + - Issue #26711: Fixed the comparison of plistlib.Data with other types. - Issue #24114: Fix an uninitialized variable in `ctypes.util`.