]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-148398: add type watcher in `_CHECK_ATTR_CLASS` (GH-148399)
authorNeko Asakura <neko.asakura@outlook.com>
Sun, 12 Apr 2026 12:54:03 +0000 (08:54 -0400)
committerGitHub <noreply@github.com>
Sun, 12 Apr 2026 12:54:03 +0000 (20:54 +0800)
Misc/NEWS.d/next/Core_and_Builtins/2026-04-11-15-12-53.gh-issue-148398.g62jCA.rst [new file with mode: 0644]
Python/optimizer_bytecodes.c
Python/optimizer_cases.c.h

diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-04-11-15-12-53.gh-issue-148398.g62jCA.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-04-11-15-12-53.gh-issue-148398.g62jCA.rst
new file mode 100644 (file)
index 0000000..0a7ba0b
--- /dev/null
@@ -0,0 +1 @@
+Fix a bug in the JIT optimizer where class attribute loads were not invalidated after type mutation.
index c12a4f4131bc7efaf7408ced3cff60054792deb5..39dc4877af8884e84934a7c9b8e085aa63ee9232 100644 (file)
@@ -226,6 +226,10 @@ dummy_func(void) {
             }
             else {
                 sym_set_const(owner, type);
+                if ((((PyTypeObject *)type)->tp_flags & Py_TPFLAGS_IMMUTABLETYPE) == 0) {
+                    PyType_Watch(TYPE_WATCHER_ID, type);
+                    _Py_BloomFilter_Add(dependencies, type);
+                }
             }
         }
     }
index 2db2c87cb3610bfb3c79fc274cca41a12f3513eb..746653906874b5caac398eabae15f7cfb3e26479 100644 (file)
                 }
                 else {
                     sym_set_const(owner, type);
+                    if ((((PyTypeObject *)type)->tp_flags & Py_TPFLAGS_IMMUTABLETYPE) == 0) {
+                        PyType_Watch(TYPE_WATCHER_ID, type);
+                        _Py_BloomFilter_Add(dependencies, type);
+                    }
                 }
             }
             break;