diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-11-22 15:30:53 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-11-22 15:30:53 +0100 |
commit | 0b87b69a6e5db7b3ddd4590439af6142dbc7bd7f (patch) | |
tree | 890f2b17e9b160c9877d8e7a02d4a877e50161aa /Modules/_sre.c | |
parent | 9ad8a639f37ded33154da1b12cddd46ab764495b (diff) | |
parent | bcf4dccfa77df6fd75181e2a7cbfbf2d4b2c6255 (diff) | |
download | cpython-git-0b87b69a6e5db7b3ddd4590439af6142dbc7bd7f.tar.gz |
Merge 3.6
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r-- | Modules/_sre.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c index c1e9fa6e6b..979e61fb53 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2683,12 +2683,18 @@ pattern_richcompare(PyObject *lefto, PyObject *righto, int op) 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; cmp = (left->flags == right->flags && left->isbytes == right->isbytes - && left->codesize && right->codesize); + && left->codesize == right->codesize); if (cmp) { /* Compare the code and the pattern because the same pattern can produce different codes depending on the locale used to compile the |