diff options
author | Brandt Bucher <brandtbucher@gmail.com> | 2022-08-01 11:02:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-01 11:02:56 -0700 |
commit | c7e5bbaee88a71dc6e633e3cd451ed1798436382 (patch) | |
tree | bc1fd93fbb18b2745ebc1956ea5448a19f5bbdf1 /Objects/codeobject.c | |
parent | a95e60db748ec6f2c19b5710c11f62e1e4d669f4 (diff) | |
download | cpython-c7e5bbaee88a71dc6e633e3cd451ed1798436382.tar.gz cpython-c7e5bbaee88a71dc6e633e3cd451ed1798436382.zip |
GH-95150: Use position and exception tables for code hashing and equality (GH-95509)
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r-- | Objects/codeobject.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 2f757c4d8a9..7ebbfdbdec1 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -1695,6 +1695,15 @@ code_richcompare(PyObject *self, PyObject *other, int op) eq = PyObject_RichCompareBool(co->co_localsplusnames, cp->co_localsplusnames, Py_EQ); if (eq <= 0) goto unequal; + eq = PyObject_RichCompareBool(co->co_linetable, cp->co_linetable, Py_EQ); + if (eq <= 0) { + goto unequal; + } + eq = PyObject_RichCompareBool(co->co_exceptiontable, + cp->co_exceptiontable, Py_EQ); + if (eq <= 0) { + goto unequal; + } if (op == Py_EQ) res = Py_True; @@ -1727,7 +1736,15 @@ code_hash(PyCodeObject *co) if (h2 == -1) return -1; h3 = PyObject_Hash(co->co_localsplusnames); if (h3 == -1) return -1; - h = h0 ^ h1 ^ h2 ^ h3 ^ + Py_hash_t h4 = PyObject_Hash(co->co_linetable); + if (h4 == -1) { + return -1; + } + Py_hash_t h5 = PyObject_Hash(co->co_exceptiontable); + if (h5 == -1) { + return -1; + } + h = h0 ^ h1 ^ h2 ^ h3 ^ h4 ^ h5 ^ co->co_argcount ^ co->co_posonlyargcount ^ co->co_kwonlyargcount ^ co->co_flags; if (h == -1) h = -2; |