xmlrpc.client.loads raises IndexError on a malformed struct
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
- gh-153805
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Unmarshaller.end_struct, where the issue identifies the pairwise iteration that raises IndexError, and compare it with the existing malformed-input handling around lines 640 and 663. Done means the reproducer raises xmlrpc.client.ResponseError rather than IndexError; linked PR gh-153805 indicates that work is already underway.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100