From 55c6ec60926173357814b5893346d3cfc97221e5 Mon Sep 17 00:00:00 2001 From: J08nY Date: Mon, 26 Aug 2024 10:49:55 +0200 Subject: [PATCH] Protect Symbol.__eq__ by instance check. This avoids an AttributeError when comparing to other objects. --- jsondiff/symbols.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jsondiff/symbols.py b/jsondiff/symbols.py index 48396b5..c5402ea 100644 --- a/jsondiff/symbols.py +++ b/jsondiff/symbols.py @@ -36,8 +36,10 @@ def __str__(self): return "$" + self.label def __eq__(self, other): + if not isinstance(other, Symbol): + return False return self.label == other.label - + def __hash__(self) -> int: return hash(self.label)