From 2c80dd5505d748ded5db838cea76e456f6625123 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Tue, 29 Nov 2016 11:33:24 +0100 Subject: [PATCH] [bugfix] Use base classes for ImmutableRecord in correct order A very weird bug: The order of base classes actually matters here, because if __hash__ and __eq__ are defined in the wrong order, __hash__ will get deleted (in 3). MWE: ``` class X(object): def __eq__(self, other): return True class Y(object): def __hash__(self): return 0 class Z1(Y,X): pass class Z2(X,Y): pass hash(Z1()) hash(Z2()) ``` --- pytools/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytools/__init__.py b/pytools/__init__.py index 9915990..a02855c 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -207,7 +207,7 @@ class ImmutableRecordWithoutPickling(RecordWithoutPickling): for field in self.__class__.fields)) -class ImmutableRecord(Record, ImmutableRecordWithoutPickling): +class ImmutableRecord(ImmutableRecordWithoutPickling, Record): pass # }}} -- GitLab