]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-125610: Fix `STORE_ATTR_INSTANCE_VALUE` specialization check (GH-125612...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 6 Dec 2024 16:14:26 +0000 (17:14 +0100)
committerGitHub <noreply@github.com>
Fri, 6 Dec 2024 16:14:26 +0000 (16:14 +0000)
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.
(cherry picked from commit a353455fca1b8f468ff3ffbb4b5e316510b4fd43)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Python/specialize.c

index 1a2043d0e8dc11f68901cc44a8a3cbf75ea1ef25..ad166ea091be9da40f3259706dc9ae6d3cfc97b9 100644 (file)
@@ -841,7 +841,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);