Skip to content

gh-71468: Make xmlrpc.client.Fault and ProtocolError picklable - #161016

Open
b84330808 wants to merge 1 commit into
python:mainfrom
b84330808:gh-71468-xmlrpc-exception-pickle
Open

b84330808 wants to merge 1 commit into
python:mainfrom
b84330808:gh-71468-xmlrpc-exception-pickle

Conversation

@b84330808

@b84330808 b84330808 commented Oct 31, 2026 •

Copy link
Copy Markdown

Fault and ProtocolError call Error.__init__() without arguments, so args is empty and unpickling calls the constructor with no arguments:

>>> pickle.loads(pickle.dumps(xmlrpc.client.Fault(42, "x")))
TypeError: Fault.__init__() missing 2 required positional arguments: 'faultCode' and 'faultString'

This passes the constructor arguments to Error.__init__(), the same way the configparser and smtplib exceptions do. This matters for multiprocessing, which pickles exceptions raised in workers. str() and repr() don't change (Error.__str__ is object.__str__); the only visible difference is that args now holds the constructor arguments instead of ().

I used Claude Code to write this change.

Both exceptions called Error.__init__() without arguments, so args was
empty and unpickling called the constructor with no arguments, which
raised TypeError. Pass the constructor arguments to Error.__init__(),
as configparser and smtplib exceptions do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant