From b6016554cca65599440608f68d2e46d8c6d07e28 Mon Sep 17 00:00:00 2001 From: Tim Rid <6593626+timrid@users.noreply.github.com> Date: Sun, 21 Feb 2021 00:13:45 +0100 Subject: [PATCH] adapted the "TContainerBase" to the "TContainer" of construct v2.10.61 based on an OrderedDict --- construct_typed/tstruct.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/construct_typed/tstruct.py b/construct_typed/tstruct.py index e23d83f..66c3b08 100644 --- a/construct_typed/tstruct.py +++ b/construct_typed/tstruct.py @@ -40,15 +40,14 @@ class TContainerBase(_TContainerBase): return super().__getattribute__(name) def __post_init__(self) -> None: - # 1. fix the __keys_order__ of the cs.Container - # 2. append fields with init=False to the dict of the cs.Container - self.__keys_order__ = [] + # 1. append fields with init=False to the dict of the cs.Container + # 2. fix the order of the OrderedDict for field in dataclasses.fields(self): value = getattr(self, field.name) - if field.init is True: - self.__keys_order__.append(field.name) - else: + if field.init is False: self[field.name] = value + else: + self.move_to_end(field.name) def TStructField(