Erez Zinman <erezinman.program...@gmail.com> added the comment:
Looking at the implementation of `__init__` (https://github.com/python/cpython/blob/76553e5d2eae3e8a47406a6de4f354fe33ff370b/Lib/collections/__init__.py#L109), it seems that you can fix this bug while retaining backward compatibility if you would use `__new__` in the `__reduce__` function, followed by an `OrderedDict.__init__`. The difference is that you don't call `__class__.__init__`, but rather `OrderedDict.__init__`. Some thing like the following: def __reduce__(self): 'Return state information for pickling' inst_dict = vars(self).copy() for k in vars(OrderedDict()): inst_dict.pop(k, None) def initializer(): inst = __class__.__new__(__class__) OrderedDict.__init__(inst) return initializer, (), inst_dict or None, None, iter(self.items()) The items will "restored" later using the `odict_iter`. ---------- _______________________________________ 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