Erez Zinman <erezinman.program...@gmail.com> added the comment:
Just to be clear, what I did is (works with both "copy" and "pickle"): ``` def _new_and_init(cls): inst = cls.__new__(cls) OrderedDict.__init__(inst) return inst class A(OrderedDict): def __reduce__(self): # This fixes a bug in Python 3.6 ret = list(super().__reduce__()) ret[0] = _new_and_init ret[1] = (self.__class__, ) return tuple(ret) ``` And that works... I also verified that indeed old->new pickling will just call _init__ on unpickling, so this would just retain the previous behavior. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41751> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com