mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Merge 3.6
This commit is contained in:
commit
0b87b69a6e
2 changed files with 11 additions and 1 deletions
|
@ -1781,6 +1781,10 @@ SUBPATTERN None 0 0
|
||||||
def test_pattern_compare(self):
|
def test_pattern_compare(self):
|
||||||
pattern1 = re.compile('abc', re.IGNORECASE)
|
pattern1 = re.compile('abc', re.IGNORECASE)
|
||||||
|
|
||||||
|
# equal to itself
|
||||||
|
self.assertEqual(pattern1, pattern1)
|
||||||
|
self.assertFalse(pattern1 != pattern1)
|
||||||
|
|
||||||
# equal
|
# equal
|
||||||
re.purge()
|
re.purge()
|
||||||
pattern2 = re.compile('abc', re.IGNORECASE)
|
pattern2 = re.compile('abc', re.IGNORECASE)
|
||||||
|
|
|
@ -2683,12 +2683,18 @@ pattern_richcompare(PyObject *lefto, PyObject *righto, int op)
|
||||||
if (Py_TYPE(lefto) != &Pattern_Type || Py_TYPE(righto) != &Pattern_Type) {
|
if (Py_TYPE(lefto) != &Pattern_Type || Py_TYPE(righto) != &Pattern_Type) {
|
||||||
Py_RETURN_NOTIMPLEMENTED;
|
Py_RETURN_NOTIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lefto == righto) {
|
||||||
|
/* a pattern is equal to itself */
|
||||||
|
return PyBool_FromLong(op == Py_EQ);
|
||||||
|
}
|
||||||
|
|
||||||
left = (PatternObject *)lefto;
|
left = (PatternObject *)lefto;
|
||||||
right = (PatternObject *)righto;
|
right = (PatternObject *)righto;
|
||||||
|
|
||||||
cmp = (left->flags == right->flags
|
cmp = (left->flags == right->flags
|
||||||
&& left->isbytes == right->isbytes
|
&& left->isbytes == right->isbytes
|
||||||
&& left->codesize && right->codesize);
|
&& left->codesize == right->codesize);
|
||||||
if (cmp) {
|
if (cmp) {
|
||||||
/* Compare the code and the pattern because the same pattern can
|
/* Compare the code and the pattern because the same pattern can
|
||||||
produce different codes depending on the locale used to compile the
|
produce different codes depending on the locale used to compile the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue