From 7d96e569a1b5f4505dac8d6f24c4b27562acf875 Mon Sep 17 00:00:00 2001 From: Paul McGuire Date: Sat, 13 Jul 2019 12:46:14 -0500 Subject: Update `__eq__` to Py2/Py3 compat --- pyparsing.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pyparsing.py') diff --git a/pyparsing.py b/pyparsing.py index 1d532af..5ca86b0 100644 --- a/pyparsing.py +++ b/pyparsing.py @@ -2556,9 +2556,12 @@ class ParserElement(object): # catch and re-raise exception from here, clears out pyparsing internal stack trace raise exc - def __eq__(self,other): + def __eq__(self, other): if isinstance(other, ParserElement): - super(ParserElement, self).__eq__(other) + if PY_3: + self is other or super(ParserElement, self).__eq__(other) + else: + return self is other or vars(self) == vars(other) elif isinstance(other, basestring): return self.matches(other) else: -- cgit v1.2.1