From a03e1a7c4735593dccd416d9e73cfe2a3eebb789 Mon Sep 17 00:00:00 2001 From: joodicator Date: Wed, 3 Jul 2019 19:53:30 +0200 Subject: [PATCH] Fix: MutableRecord interprets __slots__ incorrectly (issue #133) --- minecraft/networking/types/utility.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/minecraft/networking/types/utility.py b/minecraft/networking/types/utility.py index 3e5a48e..2916437 100644 --- a/minecraft/networking/types/utility.py +++ b/minecraft/networking/types/utility.py @@ -65,7 +65,8 @@ class MutableRecord(object): def __repr__(self): return '%s(%s)' % (type(self).__name__, ', '.join( - '%s=%r' % (a, getattr(self, a)) for a in self._all_slots())) + '%s=%r' % (a, getattr(self, a)) for a in self._all_slots() + if hasattr(self, a))) def __eq__(self, other): return type(self) is type(other) and all( @@ -83,8 +84,11 @@ class MutableRecord(object): @classmethod def _all_slots(cls): - return tuple(f for c in reversed(cls.__mro__) - for f in getattr(c, '__slots__', ())) + for supcls in reversed(cls.__mro__): + slots = supcls.__dict__.get('__slots__', ()) + slots = (slots,) if isinstance(slots, str) else slots + for slot in slots: + yield slot def attribute_alias(name):