changeset: 101222:8f7cb3b171f3 parent: 101220:811ccdee6f87 parent: 101221:0d015f6aba8b user: Serhiy Storchaka date: Wed May 04 11:27:17 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 811ccdee6f87 -r 8f7cb3b171f3 Lib/test/test_xmlrpc.py --- a/Lib/test/test_xmlrpc.py Wed May 04 09:44:44 2016 +0300 +++ b/Lib/test/test_xmlrpc.py Wed May 04 11:27:17 2016 +0300 @@ -223,6 +223,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 811ccdee6f87 -r 8f7cb3b171f3 Lib/xmlrpc/client.py --- a/Lib/xmlrpc/client.py Wed May 04 09:44:44 2016 +0300 +++ b/Lib/xmlrpc/client.py Wed May 04 11:27:17 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 811ccdee6f87 -r 8f7cb3b171f3 Misc/NEWS --- a/Misc/NEWS Wed May 04 09:44:44 2016 +0300 +++ b/Misc/NEWS Wed May 04 11:27:17 2016 +0300 @@ -256,6 +256,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`.