Bug description
xmlrpc.client.loads() raises a raw IndexError instead of xmlrpc.client.ResponseError when unmarshalling a <struct> that contains a <member> with a <name> but no <value>.
Unmarshaller.end_struct iterates the stacked items in pairs (items[i], items[i+1]). A <member> missing its <value> leaves an odd number of items, so items[i+1] raises IndexError.
The unmarshaller already raises ResponseError for sibling malformed cases (empty stack at line 640, unknown tag inside <data> at line 663).
Reproducer:
import xmlrpc.client
data = (b'<?xml version="1.0"?>'
b'<methodResponse><params><param><value>'
b'<struct><member><name>k</name></member></struct>'
b'</value></param></params></methodResponse>')
xmlrpc.client.loads(data)
# IndexError: list index out of range
Expected: xmlrpc.client.ResponseError.
CPython versions tested on
3.13, 3.14, 3.15, main
Operating systems tested on
macOS
Linked PRs
Bug description
xmlrpc.client.loads()raises a rawIndexErrorinstead ofxmlrpc.client.ResponseErrorwhen unmarshalling a<struct>that contains a<member>with a<name>but no<value>.Unmarshaller.end_structiterates the stacked items in pairs (items[i], items[i+1]). A<member>missing its<value>leaves an odd number of items, soitems[i+1]raisesIndexError.The unmarshaller already raises
ResponseErrorfor sibling malformed cases (empty stack at line 640, unknown tag inside<data>at line 663).Reproducer:
Expected:
xmlrpc.client.ResponseError.CPython versions tested on
3.13, 3.14, 3.15, main
Operating systems tested on
macOS
Linked PRs