Skip to content

Commit 711f858

Browse files
committed
Hydrate code object in rich comparison
1 parent e46a6b2 commit 711f858

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Objects/codeobject.c

+13
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,19 @@ code_richcompare(PyObject *self, PyObject *other, int op)
14771477
if (!eq) goto unequal;
14781478
eq = co->co_firstlineno == cp->co_firstlineno;
14791479
if (!eq) goto unequal;
1480+
1481+
// Must hydrate before we touch other fields
1482+
if (!_PyCode_IsHydrated(co)) {
1483+
if (_PyCode_Hydrate(co) == NULL) {
1484+
return NULL;
1485+
}
1486+
}
1487+
if (!_PyCode_IsHydrated(cp)) {
1488+
if (_PyCode_Hydrate(cp) == NULL) {
1489+
return NULL;
1490+
}
1491+
}
1492+
14801493
eq = PyObject_RichCompareBool(co->co_code, cp->co_code, Py_EQ);
14811494
if (eq <= 0) goto unequal;
14821495

0 commit comments

Comments
 (0)