Skip to content

Commit 8b7e7eb

Browse files
colesburysrinivasreddy
authored andcommitted
pythongh-125610: Fix STORE_ATTR_INSTANCE_VALUE specialization check (pythonGH-125612)
The `STORE_ATTR_INSTANCE_VALUE` opcode doesn't support objects with non-NULL managed dictionaries, so don't specialize to that op in that case.
1 parent 3e0f748 commit 8b7e7eb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/specialize.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,10 @@ specialize_dict_access(
947947
return 0;
948948
}
949949
_PyAttrCache *cache = (_PyAttrCache *)(instr + 1);
950-
if (type->tp_flags & Py_TPFLAGS_INLINE_VALUES && _PyObject_InlineValues(owner)->valid) {
950+
if (type->tp_flags & Py_TPFLAGS_INLINE_VALUES &&
951+
_PyObject_InlineValues(owner)->valid &&
952+
!(base_op == STORE_ATTR && _PyObject_GetManagedDict(owner) != NULL))
953+
{
951954
PyDictKeysObject *keys = ((PyHeapTypeObject *)type)->ht_cached_keys;
952955
assert(PyUnicode_CheckExact(name));
953956
Py_ssize_t index = _PyDictKeys_StringLookup(keys, name);

0 commit comments

Comments
 (0)