From 7a4750aa860ca1b192c02fe48f4907c33a4f0435 Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Sun, 17 Nov 2019 21:52:49 +0100 Subject: [PATCH] Fixed autoeq in case of attributeerror --- autoclass/autoeq_.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/autoclass/autoeq_.py b/autoclass/autoeq_.py index edb49e4..10f7708 100644 --- a/autoclass/autoeq_.py +++ b/autoclass/autoeq_.py @@ -157,10 +157,14 @@ def __eq__(self, other): """ Generated by @autoeq. Relies on the hardcoded list of field names and "getattr" (object) for the value. """ - for att_name in selected_names: - if getattr(self, att_name) != getattr(other, att_name): - return False - return True + try: + for att_name in selected_names: + if getattr(self, att_name) != getattr(other, att_name): + return False + except AttributeError: + return False + else: + return True return __eq__