From 221a7c99736ba5286f207a6fde727660429039de Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 13 Apr 2022 10:37:07 +0200 Subject: [PATCH] fix(core): drop support for __slots__ from obj_eq / obj_repr __slots__ are unsupported in micropython [no changelog] --- core/src/trezor/utils.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/core/src/trezor/utils.py b/core/src/trezor/utils.py index ab8f4ff5c..0263fa3ed 100644 --- a/core/src/trezor/utils.py +++ b/core/src/trezor/utils.py @@ -304,29 +304,20 @@ class BufferReader: def obj_eq(self: Any, __o: Any) -> bool: """ - Compares object contents, supports __slots__. + Compares object contents. """ if self.__class__ is not __o.__class__: return False - if not hasattr(self, "__slots__"): - return self.__dict__ == __o.__dict__ - if self.__slots__ is not __o.__slots__: - return False - for slot in self.__slots__: - if getattr(self, slot, None) != getattr(__o, slot, None): - return False - return True + assert not hasattr(self, "__slots__") + return self.__dict__ == __o.__dict__ def obj_repr(self: Any) -> str: """ - Returns a string representation of object, supports __slots__. + Returns a string representation of object. """ - if hasattr(self, "__slots__"): - d = {attr: getattr(self, attr, None) for attr in self.__slots__} - else: - d = self.__dict__ - return f"<{self.__class__.__name__}: {d}>" + assert not hasattr(self, "__slots__") + return f"<{self.__class__.__name__}: {self.__dict__}>" def truncate_utf8(string: str, max_bytes: int) -> str: