]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-125610: Fix `STORE_ATTR_INSTANCE_VALUE` specialization check (GH-125612)
authorSam Gross <colesbury@gmail.com>
Fri, 6 Dec 2024 15:48:24 +0000 (15:48 +0000)
committerGitHub <noreply@github.com>
Fri, 6 Dec 2024 15:48:24 +0000 (10:48 -0500)
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.

Python/specialize.c

index ec2cd7025e5054abaa738ea07ec80afeed2b6467..d3fea7172438474c9ec89acccd0fe41171048d91 100644 (file)
@@ -947,7 +947,10 @@ specialize_dict_access(
         return 0;
     }
     _PyAttrCache *cache = (_PyAttrCache *)(instr + 1);
-    if (type->tp_flags & Py_TPFLAGS_INLINE_VALUES && _PyObject_InlineValues(owner)->valid) {
+    if (type->tp_flags & Py_TPFLAGS_INLINE_VALUES &&
+        _PyObject_InlineValues(owner)->valid &&
+        !(base_op == STORE_ATTR && _PyObject_GetManagedDict(owner) != NULL))
+    {
         PyDictKeysObject *keys = ((PyHeapTypeObject *)type)->ht_cached_keys;
         assert(PyUnicode_CheckExact(name));
         Py_ssize_t index = _PyDictKeys_StringLookup(keys, name);