Skip to content

Commit

Permalink
GH-93911: Fix LOAD_ATTR_PROPERTY caches (GH-96519)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandtbucher authored Sep 6, 2022
1 parent f177f6f commit cd0ff9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix an issue that could prevent :opcode:`LOAD_ATTR` from specializing
properly when accessing properties.
10 changes: 5 additions & 5 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,10 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name)
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_PROPERTY_NOT_PY_FUNCTION);
goto fail;
}
uint32_t version = function_check_args(fget, 1, LOAD_ATTR) &&
function_get_version(fget, LOAD_ATTR);
if (!function_check_args(fget, 1, LOAD_ATTR)) {
goto fail;
}
uint32_t version = function_get_version(fget, LOAD_ATTR);
if (version == 0) {
goto fail;
}
Expand Down Expand Up @@ -831,9 +833,7 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name)
assert(type->tp_getattro == _Py_slot_tp_getattro);
assert(Py_IS_TYPE(descr, &PyFunction_Type));
_PyLoadMethodCache *lm_cache = (_PyLoadMethodCache *)(instr + 1);
uint32_t func_version = function_check_args(descr, 2, LOAD_ATTR) &&
function_get_version(descr, LOAD_ATTR);
if (func_version == 0) {
if (!function_check_args(descr, 2, LOAD_ATTR)) {
goto fail;
}
/* borrowed */
Expand Down

0 comments on commit cd0ff9b

Please sign in to comment.