From: Dmitry Selyutin Date: Sat, 10 Jun 2023 19:50:54 +0000 (+0300) Subject: insndb/core: make Dict almost immutable X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae11ea014fc21a62691c58e07aa48bd5100bfcf9;p=openpower-isa.git insndb/core: make Dict almost immutable --- diff --git a/src/openpower/insndb/core.py b/src/openpower/insndb/core.py index d0425ff8..b9f681b6 100644 --- a/src/openpower/insndb/core.py +++ b/src/openpower/insndb/core.py @@ -124,6 +124,27 @@ class Dict(Node, dict): cls.__datatype = datatype return super().__init_subclass__() + def __hash__(self): + return hash(tuple(sorted(self.items()))) + + def clear(self): + raise NotImplementedError() + + def __delitem__(self, key): + raise NotImplementedError() + + def __setitem__(self, key, value): + raise NotImplementedError() + + def popitem(self) -> tuple: + raise NotImplementedError() + + def pop(self, key, default=None): + raise NotImplementedError() + + def update(self, entry, **kwargs): + raise NotImplementedError() + @walkmethod def walk(clsself, match=None): if match is None: @@ -756,9 +777,6 @@ class Fields(Dict, datatype=type("Bits", (Tuple,), {}, datatype=int)): return super().__init__(mapping) - def __hash__(self): - return hash(tuple(sorted(self.items()))) - def __iter__(self): yield from self.__mapping.items()