From: Neko Asakura Date: Sun, 12 Apr 2026 12:54:03 +0000 (-0400) Subject: gh-148398: add type watcher in `_CHECK_ATTR_CLASS` (GH-148399) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=30c698a655bafdb53db0d39426a2b5cfce3b19ca;p=thirdparty%2FPython%2Fcpython.git gh-148398: add type watcher in `_CHECK_ATTR_CLASS` (GH-148399) --- 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 index 000000000000..0a7ba0b27d97 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-04-11-15-12-53.gh-issue-148398.g62jCA.rst @@ -0,0 +1 @@ +Fix a bug in the JIT optimizer where class attribute loads were not invalidated after type mutation. diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index c12a4f4131bc..39dc4877af88 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -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); + } } } } diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h index 2db2c87cb361..746653906874 100644 --- a/Python/optimizer_cases.c.h +++ b/Python/optimizer_cases.c.h @@ -2571,6 +2571,10 @@ } 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;