Skip to content

Commit cd0ff9b

Browse files
authored
GH-93911: Fix LOAD_ATTR_PROPERTY caches (GH-96519)
1 parent f177f6f commit cd0ff9b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix an issue that could prevent :opcode:`LOAD_ATTR` from specializing
2+
properly when accessing properties.

Python/specialize.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,10 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name)
775775
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_PROPERTY_NOT_PY_FUNCTION);
776776
goto fail;
777777
}
778-
uint32_t version = function_check_args(fget, 1, LOAD_ATTR) &&
779-
function_get_version(fget, LOAD_ATTR);
778+
if (!function_check_args(fget, 1, LOAD_ATTR)) {
779+
goto fail;
780+
}
781+
uint32_t version = function_get_version(fget, LOAD_ATTR);
780782
if (version == 0) {
781783
goto fail;
782784
}
@@ -831,9 +833,7 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name)
831833
assert(type->tp_getattro == _Py_slot_tp_getattro);
832834
assert(Py_IS_TYPE(descr, &PyFunction_Type));
833835
_PyLoadMethodCache *lm_cache = (_PyLoadMethodCache *)(instr + 1);
834-
uint32_t func_version = function_check_args(descr, 2, LOAD_ATTR) &&
835-
function_get_version(descr, LOAD_ATTR);
836-
if (func_version == 0) {
836+
if (!function_check_args(descr, 2, LOAD_ATTR)) {
837837
goto fail;
838838
}
839839
/* borrowed */

0 commit comments

Comments
 (0)