2 Dec 11:41
Pickle 3 and keyword arguments in __new__ after *
Zaur Shibzoukhov <szport <at> gmail.com>
2008-12-02 10:41:46 GMT
2008-12-02 10:41:46 GMT
This is a case:
class C(object):
def __new__(cls, *, b):
inst = super().__new__(cls)
inst.b = b
return inst
>>> c = C(b=17)
>>> image = pickle.dumps(c, protocol=3)
>>> c = pickle.loads(image)
Traceback (most recent call last):
File "test_new.py", line 17, in <module>
c = pickle.loads(image)
File "D:\Python30\lib\pickle.py", line 1329, in loads
return Unpickler(file, encoding=encoding, errors=errors).load()
TypeError: __new__() needs keyword-only argument b
Do we need to improve pickle protocol in order to allow instance
creation functions get keyword arguments too?
Best regards,
Zaur
RSS Feed