From 1b555d2f98aa6d9527f291780495c47fb9d63f89 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 2 Sep 2022 16:34:33 -0700 Subject: [PATCH 1/2] Fix incorrect version calculations for LOAD_ATTR --- Python/specialize.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Python/specialize.c b/Python/specialize.c index e8c3f468feaa47..299adf34528a58 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -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 */ From b7e73249b62afe3429322e3d44e0c57c805200d6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 2 Sep 2022 16:48:02 -0700 Subject: [PATCH 2/2] blurb add --- .../2022-09-02-16-47-52.gh-issue-93911.vF-GWe.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-09-02-16-47-52.gh-issue-93911.vF-GWe.rst 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 index 00000000000000..b8dc0435377b5f --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-09-02-16-47-52.gh-issue-93911.vF-GWe.rst @@ -0,0 +1,2 @@ +Fix an issue that could prevent :opcode:`LOAD_ATTR` from specializing +properly when accessing properties.