Message268028
Attempting to unpickle an xmlrpc.client.Fault will raise a TypeError:
>>> import xmlrpc.client as xmlrpclib
>>> f = xmlrpclib.Fault(42, 'Test Fault')
>>> import pickle
>>> s = pickle.dumps(f)
>>> pickle.loads(s)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() missing 2 required positional arguments: 'faultCode' and 'faultString'
Apparently unpickle relies on BaseException's args attribute when reconstructing an Exception class that inherits from BaseException (Fault inherits from Exception). Unfortunately, Fault implements __init__() and does call the base class constructor, but does not pass its arguments, so Fault.args is always an empty tuple.
Simply passing Fault's arguments to the base class constructor allows it to be unpickled.
I've included a patch for 3.x but the issue is present in 2.x as well (the code and fix are exactly the same except in xmlrpclib.py). |
|
Date |
User |
Action |
Args |
2016-06-09 15:09:16 | Uri Okrent | set | recipients:
+ Uri Okrent |
2016-06-09 15:09:16 | Uri Okrent | set | messageid: <1465484956.65.0.651270200726.issue27281@psf.upfronthosting.co.za> |
2016-06-09 15:09:16 | Uri Okrent | link | issue27281 messages |
2016-06-09 15:09:16 | Uri Okrent | create | |
|