diff -r 8ab8f5259f09 Lib/test/test_xmlrpc.py --- a/Lib/test/test_xmlrpc.py Wed Apr 27 23:13:46 2016 +0300 +++ b/Lib/test/test_xmlrpc.py Thu Apr 28 22:40:43 2016 +0300 @@ -223,6 +223,19 @@ class XMLRPCTestCase(unittest.TestCase): self.assertIs(type(newvalue), xmlrpclib.Binary) self.assertIsNone(m) + def test_loads_unsupported(self): + data = '' + self.assertRaises(ValueError, xmlrpclib.loads, data) + data = ('' + '' + '') + self.assertRaises(ValueError, xmlrpclib.loads, data) + data = ('' + 'a' + 'b' + '') + self.assertRaises(ValueError, xmlrpclib.loads, data) + def test_get_host_info(self): # see bug #3613, this raised a TypeError transp = xmlrpc.client.Transport() diff -r 8ab8f5259f09 Lib/xmlrpc/client.py --- a/Lib/xmlrpc/client.py Wed Apr 27 23:13:46 2016 +0300 +++ b/Lib/xmlrpc/client.py Thu Apr 28 22:40:43 2016 +0300 @@ -640,6 +640,7 @@ class Unmarshaller: 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 @@ class Unmarshaller: if tag == "array" or tag == "struct": self._marks.append(len(self._stack)) self._data = [] + if self._value and tag not in self.dispatch: + raise ValueError("unknown tag %r" % tag) self._value = (tag == "value") def data(self, text):