[Python-3000] Pickle 3 and keyword arguments in __new__ after *

Zaur Shibzoukhov szport at gmail.com
Tue Dec 2 11:41:46 CET 2008


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


More information about the Python-3000 mailing list