]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-93911: Fix `LOAD_ATTR_PROPERTY` caches (GH-96519)
authorBrandt Bucher <brandtbucher@microsoft.com>
Tue, 6 Sep 2022 11:11:38 +0000 (04:11 -0700)
committerGitHub <noreply@github.com>
Tue, 6 Sep 2022 11:11:38 +0000 (12:11 +0100)
Misc/NEWS.d/next/Core and Builtins/2022-09-02-16-47-52.gh-issue-93911.vF-GWe.rst [new file with mode: 0644]
Python/specialize.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-09-02-16-47-52.gh-issue-93911.vF-GWe.rst b/Misc/NEWS.d/next/Core and Builtins/2022-09-02-16-47-52.gh-issue-93911.vF-GWe.rst
new file mode 100644 (file)
index 0000000..b8dc043
--- /dev/null
@@ -0,0 +1,2 @@
+Fix an issue that could prevent :opcode:`LOAD_ATTR` from specializing
+properly when accessing properties.
index e8c3f468feaa4765ee26721222adeebf57397a05..299adf34528a587e28b86b6b2b4807e67330a259 100644 (file)
@@ -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;
             }
@@ -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 */