diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 4082201a25ea77..6894a0a57455e7 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1977,7 +1977,7 @@ dummy_func( #endif /* ENABLE_SPECIALIZATION */ } - op(_LOAD_ATTR, (owner -- attr: _PyStackRef *, self_or_null if (oparg & 1))) { + op(_LOAD_ATTR, (owner -- attr[1], self_or_null if (oparg & 1))) { PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1); if (oparg & 1) { /* Designed to work in tandem with CALL, pushes two values. */ @@ -2004,7 +2004,8 @@ dummy_func( } else { /* Classic, pushes one value. */ - *attr = PyStackRef_FromPyObjectSteal(PyObject_GetAttr(PyStackRef_AsPyObjectBorrow(owner), name)); + PyObject *attr_o = PyObject_GetAttr(PyStackRef_AsPyObjectBorrow(owner), name); + *attr = attr_o == NULL ? PyStackRef_NULL : PyStackRef_FromPyObjectSteal(attr_o); DECREF_INPUTS(); ERROR_IF(PyStackRef_IsNull(*attr), error); } diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 2ede2572ab8886..8d3bdd96ee86e1 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -2204,6 +2204,7 @@ _PyStackRef self_or_null = PyStackRef_NULL; oparg = CURRENT_OPARG(); owner = stack_pointer[-1]; + attr = &stack_pointer[-1]; PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1); if (oparg & 1) { /* Designed to work in tandem with CALL, pushes two values. */ @@ -2230,11 +2231,11 @@ } else { /* Classic, pushes one value. */ - *attr = PyStackRef_FromPyObjectSteal(PyObject_GetAttr(PyStackRef_AsPyObjectBorrow(owner), name)); + PyObject *attr_o = PyObject_GetAttr(PyStackRef_AsPyObjectBorrow(owner), name); + *attr = attr_o == NULL ? PyStackRef_NULL : PyStackRef_FromPyObjectSteal(attr_o); PyStackRef_CLOSE(owner); if (PyStackRef_IsNull(*attr)) JUMP_TO_ERROR(); } - stack_pointer[-1].bits = (uintptr_t)attr; if (oparg & 1) stack_pointer[0] = self_or_null; stack_pointer += (oparg & 1); assert(WITHIN_STACK_BOUNDS()); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 0c9c93f526c021..5ccba597d8af72 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -4854,6 +4854,7 @@ /* Skip 8 cache entries */ // _LOAD_ATTR { + attr = &stack_pointer[-1]; PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1); if (oparg & 1) { /* Designed to work in tandem with CALL, pushes two values. */ @@ -4880,12 +4881,12 @@ } else { /* Classic, pushes one value. */ - *attr = PyStackRef_FromPyObjectSteal(PyObject_GetAttr(PyStackRef_AsPyObjectBorrow(owner), name)); + PyObject *attr_o = PyObject_GetAttr(PyStackRef_AsPyObjectBorrow(owner), name); + *attr = attr_o == NULL ? PyStackRef_NULL : PyStackRef_FromPyObjectSteal(attr_o); PyStackRef_CLOSE(owner); if (PyStackRef_IsNull(*attr)) goto pop_1_error; } } - stack_pointer[-1].bits = (uintptr_t)attr; if (oparg & 1) stack_pointer[0] = self_or_null; stack_pointer += (oparg & 1); assert(WITHIN_STACK_BOUNDS());