A pattern is equal to itself.
def test_pattern_compare(self):
pattern1 = re.compile('abc', re.IGNORECASE)
+ # equal to itself
+ self.assertEqual(pattern1, pattern1)
+ self.assertFalse(pattern1 != pattern1)
+
# equal
re.purge()
pattern2 = re.compile('abc', re.IGNORECASE)
if (Py_TYPE(lefto) != &Pattern_Type || Py_TYPE(righto) != &Pattern_Type) {
Py_RETURN_NOTIMPLEMENTED;
}
+
+ if (lefto == righto) {
+ /* a pattern is equal to itself */
+ return PyBool_FromLong(op == Py_EQ);
+ }
+
left = (PatternObject *)lefto;
right = (PatternObject *)righto;